Select case and invalid use of null (1 Viewer)

marcuscoker

Registered User.
Local time
Today, 06:20
Joined
Sep 28, 2005
Messages
49
Hi Was wondering if anybody could help with a select case statement I am using to validate a form

This is the code

Dim myclinic As String
Dim myfname As String

myfname = Me.txtFirstName
myclinic = Me.frmClinic


Select Case myfname
Case Is = Null
MsgBox "Please enter a first name", vbCritical
End Select

Select Case myclinic
Case "1", "2", "3"
DoCmd.Save
DoCmd.Close
DoCmd.OpenForm "switchboard"
Case "0"
MsgBox "Please select a clinic", vbCritical

End Select

When I run this code I get the error

Run-time error '94'
Invalid use of null

The second select case works fine because the default value is 0

If anybody could help me and tell me where I am going worng that would be great

Thank

Marcus
 

KenHigg

Registered User
Local time
Today, 09:20
Joined
Jun 9, 2004
Messages
13,327
Try something like:

Code:
Dim myclinic As String
Dim myfname As String

myfname = Me.txtFirstName & ""
myclinic = Me.frmClinic

Select Case myfname
Case Is = ""
MsgBox "Please enter a first name", vbCritical
End Select

Select Case myclinic
Case "1", "2", "3"
DoCmd.Save
DoCmd.Close
DoCmd.OpenForm "switchboard"
Case "0"
MsgBox "Please select a clinic", vbCritical

End Select
 

marcuscoker

Registered User.
Local time
Today, 06:20
Joined
Sep 28, 2005
Messages
49
Thanks

Thanks Ken

That was great worked well

Thanks

Marcus
 

Users who are viewing this thread

Top Bottom