"Null" fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Some times ,when i search for something "employee name"for example,the
searching criteria don't match and the form is displayed as blanck (the
form's property "add new" is set to "no") ,all that i need is to disply a
message that says for example "No matches" and to close the form ,
I tried to use the macro condition IsNull([employee name]) and the
macros Close Form,MsgBox .....but I failed to get the desired command.
Could you help ?
Regards
 
Hi Pietro,

Can we assume that you are opening a form to display your search results? If
so, you can use code like this:

Private Sub Form_Open(Cancel As Integer)
On Error GoTo ProcError

If Me.Recordset.RecordCount = 0 Then
MsgBox "There are no records."
Cancel = True
End If

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_Open..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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

Back
Top