Updating a field

G

gavin

I have managed to get a little bit of VB working (this is very simple but I
feel very pleased with myself!) but I am sure there is a neater way of doing
it.

I want the value of Field 2 to update when any of certain values are entered
into Field 1 viz:


Private Sub Field 1_AfterUpdate()

If Me.Field 1 = "A" Then
Me.Filed 2 = "Z"
End If

If Me.Field 1 = "B" Then
Me.Field 2 = "Z"
End If

If Me.Field 1 = "C" Then
Me.Field 2 = "Z"
End If

If Me.Field 1 = "D" Then
Me.Field 2 = "Z"
End If

End Sub

I tried listing the values separated by OR and that didn't seem to work and
then separated by a comma and then by a semi-colon and neither of those
works. Can someone point me in the right direction?


Thanks,



Gavin
 
G

Geof Wyght

Gavin,
I think what you want is:
If Me.Field 1 = "A" Or Me.Field 1 = "B" (and so on) Then
Me.Field 2 = "Z"
End If
Geof Wyght
 
G

gavin

Thanks very much, Geof. I did try using OR but I obviously got the syntax
wrong!


Regards,




Gavin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top