View Full Version : This is kind of a VBA question but hey.


mythix
02-19-2002, 03:43 AM
I am making an access database for a local MOT centre for my A-level computing course. I have a form where one must select a vehicle registration (taken from table tblVechiles). I've done this using a combo box. When opne presses the button cmdOK it goes through to another form that take the selected vehicle and uses a query to gain access to that particular.
My problem is I want it to display a message box if a vehicle is not selected and cancel the opening of the next form e.g. (ignore my spelling!!!) Note combop box is called txtReg and the next form is called frmCompleteMot

private sub cmdOK()_OnClick

If txtReg = "" Then
msgbox "Ah pants u didn't select a vehicle did u???"
Else
docmd.openform frmCompleteMot
End Sub

Looks nice enough but doesn't seem 2 work? obviously theremoust b somthing in txtReg to notify there is no data selected.

Does anyone know what it is???

James Kennard

http://www.access-programmers.co.uk/ubb/wink.gif

John.Woody
02-19-2002, 09:30 AM
Try this

private sub cmdOK()_OnClick

If Isnull(txtReg) Then
msgbox "Ah pants u didn't select a vehicle did u???"
Else
docmd.openform frmCompleteMot
End Sub

mkleino
02-19-2002, 09:47 AM
What you want to use is the IsNull function:

If IsNull(textbox) Then...etc.

Hope that helps!