displaying dialouge box when no records present

ajaymansata

Registered User.
Local time
Today, 22:27
Joined
Dec 17, 2001
Messages
25
Hi
Well i am firing a query to search records and then using a form to display those results.Now is it possible without any VB Script code to display a dialogue box which says no records present.
Actually I have never worked with VB so i do not know anything about it.
My search form name is search form
It has field studid,lastname,ssn as fields to specify search criteria.
Once the button is clicked on this form a macro is fired.Depending on the fields entered an appropriate form is opened and the form opened depends on the search query.
So how can i achieve what i desire.
Thanks
Ajay
 
This is how I show the same kind of msgbox if there are no records in my search. I use the search box on the same form and allow the query to match on 3 potential fields
You could modify this by placing the code on the form_open event of your new form (Yes I know it is VB though!)

Private Sub SearchBox_AfterUpdate() 'searchbox is the name of my txtbox
Me.Requery 'remove this if you are using on form_open()
If Me.RecordsetClone.RecordCount < 1 Then
MsgBox "No matches were found for this search." & vbCrLf & vbCrLf & "Please enter a new record or try different criteria.", vbOKOnly + vbInformation, "No Search Match"
End If
End Sub

ps follow the original post, do not repost the same question so that others can see the previous answers.

[This message has been edited by Fizzio (edited 05-16-2002).]
 
Hi
I appreciate the help but as i have never done VB before i am facing a problem.
Well let me tell u exactly what i have with the right names and everything
I have a form named search form with three text fields and one search button
names of text fields are
lastname,SSN,studid,
Name of search button is search
As soon as the search button is clicked in the on click event of the button i fire a macro called search form.
Now in this macro in the condition i check whether onlu lastname,or only studid,or only ssn number or all three were entered.
say Only lastname was entered then in the action event i open a form named "when lname specifed".Now this form is a result of the query used to retrieve records corresponding to the lastname entered by the user.
Now what i want is that if the query retrieves no reocrds i should get a mssg box saying "No records present" instead of what i get now that is a form with no entry in it.
could anyone please tell me exactly where and what have i to do.
Ajay
 
Go into the form designer, select the form and in the properties box, click the events tab. On the line where it says On Open, select [event procedure] then click on the three dots beside it ...
This will open the code screen and at the cursor paste

If Me.RecordsetClone.RecordCount < 1 Then
MsgBox "No matches were found for this search." & vbCrLf & vbCrLf & "Please enter a new record or try different criteria.", vbOKOnly + vbInformation, "No Search Match"
end if
Close the Code window and save the form.

Now when you open the form, if there are no records in it, the message box will display.
HTH
 

Users who are viewing this thread

Back
Top Bottom