fill a message box with string based on selection of 2 fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a work order form that contains several fields/lookup tables. I want
to fill a text box with a certain procedure based on the location field and
the activity field..I've used the following code successfully
Private Sub ActivityCode_Exit(Cancel As Integer)
If Me.ActivityCode.Value = "H40" Then
Dim strFileSpec As String
strFileSpec = CurrentProject.Path & "\" & "rb211post.txt "
Me.problem.Value = FileContents(strFileSpec, True)
End If

End Sub
but now I need to add the 'Me.LocationCode.Value = "L22" as another
qualifier to be able to decide which procedure to place in the 'problem' text
box. I've tried using If me.locationcode.value = x & me.activitycode.value =
y then execute the Dim strfilespec = z , but nothing happens....Any help
would be appreciated....thanks
 
The & operator concatenates strings. So...

me.locationcode.value = "whichever" & me.activitycode.value = "whatever"

is deciding whether

me.locationcode.value

is equal to

"whichever" & me.activitycode.value = "whatever"

So, the answer to your question is, I think, to use


me.locationcode.value = "whichever" and me.activitycode.value = "whatever"

....and you don't need explicit references to the value property... it's the
default. So try...

if me.locationcode = "whichever" and me.activitycode = "whatever" then
 
Do you mean

If (Me.ActivityCode.Value = "H40") _
And (Me.LocationCode.Value = "L22") Then

?
 
I think so. You were using
&
where
And
was needed. The parentheses aren't essential in this particular case,
but together with the layout they make the code easier to read - which
is almost always worth taking trouble over.
 
John Nurick said:
I think so. You were using
&
where
And
was needed. The parentheses aren't essential in this particular case,
but together with the layout they make the code easier to read - which
is almost always worth taking trouble over.

Yes, I do mean that .....I take it that what you have written is the correct
syntax.?

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
everything is working great..........thanks a whole lot...
 
Back
Top