Need help with a VBScript to evaluate text field values

My existing script checks 2 text fields, MEDI_INPATIENT_FILE and MEDI_MEDICAL_FILE to see if they have a value of N/A and compares this value to its corresponding integer fields, MEDI_MEDICAL_COUNT and MEDI_INPATIENT_COUNT.  This validation is working to assure that if the text value is not N/A, that the integer field value is greater than zero (via the CheckCDate function).

What I need to do now is check and see if BOTH the text fields to assure that AT LEAST ONE of them has a value <> to N/A or Null.

Now, I need a Function to take care of this.  The reason I need a Function is that I will have other text fields to check (like this Medical example) that have scores of text fields like MEDI_MEDICAL_FILE..  In this small example, the “Medical” data type only has 2 such text fields.  Others could have up to 50.  Also, since I’m already going to the database in the existing script to obtain the text field value, I don’t want to do it a second time.

The objective is to go through each text field and assure that at least one has a value that is not N/A or null.

Dim currentRecord
Dim dApproval, dCdate
Dim strIssueID, strFileName
Dim nFileCount, nFileNameValue, nFileNameSum
strFileDefault = "n/a"
If Ext.ShellHasProp( "item" ) Then
      Set currentRecord = Shell.item
            Else
      Set currentRecord = Nothing
End If
Call GetFieldValue( currentRecord, "ISSUEID", strIssueID)
Call Ext.LogInfoMsg( "This is the value of the current record or Shell.Item: " & strIssueID)
Call GetFieldValue( currentRecord, "MEDI_MEDICAL_FILE", strFileName)
Call GetFieldValue( currentRecord, "MEDI_MEDICAL_COUNT", nFileCount)
Call CheckFileCount(strFileName, nFileCount)
Call intFileNameCounter(strFileName)
Call GetFieldValue( currentRecord, "MEDI_INPATIENT_FILE", strFileName)
Call GetFieldValue( currentRecord, "MEDI_INPATIENT_COUNT", nFileCount)
Call GetFieldValue( currentRecord, "MEDI_MEDICAL_CDATE", dCdate)
Call GetFieldValue( currentRecord, "MEDICAL_LF_APPROVAL_DATE", dApproval)
Call CheckCDate(dCdate, dApproval)
Call GetFieldValue( currentRecord, "MEDI_INPATIENT_CDATE", dCdate)
Call GetFieldValue( currentRecord, "MEDICAL_LF_APPROVAL_DATE", dApproval)
Call CheckCDate(dCdate, dApproval)
impala6Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris Raisin(Retired Analyst/Programmer)Commented:
This is trickier than I first thought.

Stand By....

Chris (Australia)
0
markdmacCommented:
Here is a simple example to do what you ask

test1a=""
test1b="something"
test2a=""
test2b=""
test3a="something"
test3b="something"
test4a="something"
test4b=""

WScript.Echo CheckIsNull (test1a,test1b)
WScript.Echo CheckIsNull (test2a,test2b)
WScript.Echo CheckIsNull (test3a,test3b)
WScript.Echo CheckIsNull (test4a,test4b)

Function CheckIsNull(f1,f2)
      If Len(f1) > 0 Or Len(f2) > 0 Then
            CheckIsNull = "Not Null"
      Else
            CheckIsNull = "Null"
      End If
End Function
0
Chris Raisin(Retired Analyst/Programmer)Commented:
I don't think that will work.

Null is not the same as "n/a" or empty.

Stand By....
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Chris Raisin(Retired Analyst/Programmer)Commented:
How about this (I assume "Null" means empty)

You could (example only) use it thus:

         Field3.text = iif( NotNullOrNA(Field1.text, Field2.text),"Has Value","NoValue")
         
If "Null" will actually be stated in the field then the code would change slightly.
(Please advise if that is so)

Cheers
Chris
   

Option Explicit
Public Function NotNullOrNA(strField11 As String, strField2 As String) As Boolean
  'Function checks to see whether at least ONE of the two
  'text fields is not empty and has a value <> "n/a"
  '(By default it returns "False")

  strField1 = Trim(LCase(strField1))
  strField2 = Trim(LCase(strField2))
  If Len(strField1) > 0 Then
    If strField1 <> "n/a" Then
      NotNullOrNA = True
      Exit Function    'no need to test any further
    End If
  End If
  If Len(strField2) > 0 Then
      If strField2 <> "n/a" Then
        NotNullOrNA = True  
        'no need to exit function here since there is no further testing  
      End If
    End If
  End If
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
markdmacCommented:
My code should work for you. Please test and report back.  Also feel free to supply a sample source file for further help.
0
impala6Author Commented:
That's intriguing, Mark - but in most cases I'm checking 30-40 text fields each with a unique field name so the Function would be huge.  Is there a way to get this to a few reusable lines of code so that I can have one variable representing the "file name" field?

I've attached a script that is doing what I need it to do, but I'm hoping there is a way to scale it down a bit.
08-HRA.vb
0
markdmacCommented:
Why would the function be any larger than the same I provided?  Pass it the names of any two variables and it will tell you if at least one has a value as you stated you were trying to do.
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Inpala6,

Have you tried my code? It returns false if the value at least one has a value that is not "n/a" is there or  Empty (as requested).

Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.