Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starts with... IF/Then Statement Comparison

Status
Not open for further replies.

tbassngal

Programmer
Feb 18, 2003
74
US
Is there a way to use a wild card (or STARTS WITH) in an if/then comparison? What I would like to do is have something like this:

If strProdSched <> "No New *" And strProdSched <> "Scheduled *" And strProdSched <> "" Then

There are varying text strings after "Scheduled..." within a specified field. Is there STARTS WITH with functionality in MS Access VBA?
 
I figured it out... with help of course but I thought I would share!

If not isnull(strProdSched) and left$(strProdSched,6) <> "No New" or left$(strProdSched,9) <> "Scheduled") Then
 
Okay my solution didn't work:

If not isnull(strProdSched) and left$(strProdSched,6) <> "No New" or left$(strProdSched,9) <> "Scheduled") Then

I am getting a syntax/compile error - what is wrong with this for I am blind to it anymore!
 
Try
If (not isnull(strProdSched)) and (left$(strProdSched,6) <> "No New" or left$(strProdSched,9) <> "Scheduled")) Then
 
This is what finally worked, thanks for your help everyone!

If Not IsNull(strProdSched) Then
If Not (strProdSched Like "No New*") Then
If Not (strProdSched Like "Schedule*") Then....
 
And this ?
If Trim(strProdSched & "") <> "" And Not (strProdSched Like "No New*" Or strProdSched Like "Schedule*") Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top