This is kind of a VBA question but hey.

  • Thread starter Thread starter mythix
  • Start date Start date
M

mythix

Guest
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

wink.gif
 
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
 
What you want to use is the IsNull function:

If IsNull(textbox) Then...etc.

Hope that helps!
 

Users who are viewing this thread

Back
Top Bottom