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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wildcard for text

Status
Not open for further replies.

rnegde

Technical User
Jan 13, 2002
23
US
This seems like it should be real simple but I can't make it work. I need the code to look at one box on the access form and put the appropriate value in another box. Box 1 is text data type. Box 2 is currency. Box 1's value may be one of several possiblities, ie;
400, 400R, 314, 315, 320.
My problem is with the 400R. This code works fine as long as it's only 400.

Private Sub Box2_GotFocus()
If Box1 = 400 Then
Box2 = 2
Else
Box2 = 1.5
End If

But, I need the if part to work on both 400 and 400R. I've tried "400?" and every other wildcard combo I could but then it either doesn't work or gives me a type mismatch error.
What I need is

If Box1 is either 400 or 400R Then
Box2 =2
Anything else Box 2 =1.5

but I can't seem to get the syntax right.
Any help would be greatly appreciated!!

 
try this
Private Sub Box2_GotFocus()
If Box1 = 400 or box1 = "400R" Then
Box2 = 2
Else
Box2 = 1.5
End If
HTH
Geoff
 
ahhh...if only it was that simple! LOL....this is the error I got.

Runtime error 13: Type mismatch
and it highlighted the
If Box1 = 400 or box1 = "400R" Then
line.

The field for Box 1 in the table is set to text.
Why does it feel like a Monday?
 
rnegde,

Use the following:

Code:
Private Sub Box2_GotFocus()
  If Box1.Value = "400" Or Box1.Value = "400R" Then
    Box2.Value = 2
  Else
    Box2.Value = 1.5
  End If
End Sub

[xlbo - I still get "Type Mismatch" error using your syntax]


Regards,
M. Smith
 
Mike....you da man!!! works like a charm!......starting to feel more like Friday already!

Thanks for the help!
Have a great week!

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top