If there is no data msg box says "No Data"

zaky

Registered User.
Local time
Today, 02:17
Joined
Apr 7, 2003
Messages
17
Hi .
I have a search form where users put phone number to search,
what i want is if the phone number they are looking for is not there a message box that says "there is no such number".
Please if anyone...

Thanx.
 
Here is an example from another post in regards to opening a form based on data enterd in a textbox

HTH
 

Attachments

try

Private Sub Form_Load()
Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.EOF Then
'MsgBox "Your Message Here.", vbOKCancel
If MsgBox("There are no forms matching this criteria", vbOKOnly, "No forms") = 1 Then
docmd.Close acForm,"formname"
End If
End If
End Sub

hope that helps
Steve
 
Steve:

Why would you put the code on the Form Load event?
 
Hi!!
I just want thank you "BOTH" jfgambit and indesisiv
for giving me your time. The sample just worked fine.You saved me lots of time.

thank you guys I realy appreciated....
 
? for jfgambit

On your form, what code would I use if I wanted it to find a phone number, but I just knew part of it?
 
jfgambit: It is just the way that i had it set up in my database that i took the example from.
 
Rich...

Private Sub Form_Load()
Dim rst As Recordset
Set rst = Me.RecordsetClone
If rst.EOF Then
'MsgBox "Your Message Here.", vbOKCancel
If MsgBox("There are no forms matching this criteria", vbOKOnly, "No forms") = 1 Then
docmd.Close acForm,"formname"
End If
End If

My misunderstanding, thought he was adding this to the form where he was entering the phone number...not the form that was loading after he entered the number....

:D
 
i have a similar problem to this only my search form opens a query and then opens a report based on that query.
when someone searches for a customer with no corresponding data i would like a message box to say no data available, and when the click ok, it will run the close event of the report
please help
 
Use the NoData event of the report
MsgBox"Some message"
Cancel=True
 
how simple
1 problem, although this closes the report if there is no data, it doesn't launch the on close event of the report
 
the on close event performs other functions as well as closing the report
 
it's not code, it's a series of macros. dirty i know but im not too hot on writing vba code as you can tell
 

Users who are viewing this thread

Back
Top Bottom