Surely this could be a Case statement?

D

Dale C Gray

Hi all, MsAccess 97

This code is on a form that a user scans a barcoded sample tube into a
field, it checks for two conditions. Surely it would be better to declare
"X" only once and then handle the rest as a case statement? I want to add
one more condition...but since "x" isn't a value, how do I do this?

Thanks in advance.

Private Sub Accn_BeforeUpdate(cancel As Integer)
Dim X As Variant, Xa As Variant
X = DLookup("[Accn]", "tblOrders", "[tblOrders]![Accn] =
Forms!frmCLRecd![accn]")
If IsNull(Me![Accn]) Then
cancel = True
ElseIf IsNull(X) Then
MsgBox "No record of " & Forms!frmCLRecd![Accn] & ". Patient has not been
registered"
cancel = True
Else
Xa = DLookup("[Korder]", "tblOrders", "[tblOrders]![Accn] =
Forms!frmCLRecd![accn]")
If Xa = True Then
MsgBox "There is a Pottasium ordered on this tube. Store separately."
cancel = True
End If
End If
Me.Accn.SelStart = 0
Me.Accn.SelLength = Len(Me.Accn)
End Sub
 

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