Msg Box

herby_one

Registered User.
Local time
Today, 12:24
Joined
Sep 30, 2004
Messages
22
Hi,
I have a form based on a query which asks the user to enter a street name. I'd like to display a msg if there are no records matching that street.

Tried using this code from SJ McAbney in another thread but with no luck.

If DCount("[ID]", "qryYourQuery") = 0 Then
MsgBox "There is no data for the information you have entered.", vbInformation, "No Records Returned."
Exit Sub
Else
DoCmd.OpenQuery "qryYourQuery"
End If

Any suggestions would be appreciated.
 
yes and no one replied
 
3 points

some question:
1. do you have a query with the name "qryYourQuery"
2. do you have in the query filed "ID"
3. the query "qryYourQuery" take the details from the form?

the basic code seems good :)

good luck
 
Dim IsThere As Variant
IsThere = DLookup("[ID]", _
"YourQuery", _
"[ID] = '" & Me.ID & "'")
If Not IsNull(IsThere) Then
MsgBox There is no data for the information you have entered.", vbInformation, "No Records Returned."
End If
 
thanks for the replies.

I tried the code & am getting a run time error:
"The expression you entered as a query parameter produced this error: 'The object doesn't contain the Automation object 'Enter area of property"

My query has the following statement asking the user to input an area:

Like "*" & [Enter area of property] & "*"

Any ideas?
 
If you used a combo box to select street names from and used that to enter the query parameters then you wouldn't have to worry about no records being returned
 
yeah your right, however there are too many street names to place in a combo box.
At present if there arn't any street names that match then the form just opens with all the fields blank. I might just have to settle and leave it at this and then the user can close the form.
 
Resolution!

A work colleague showed me a way around this problem if your interested.

Basically using the IsNull(parameter)


Private Sub Form_Load()

Me.Visible = False
If IsNull(Me.Landlord_ID) Then
Msgbox "There is no data for the information you have entered.", vbInformation, "No Records Returned."
Command0_Click
Exit Sub
Else
Me.Visible = True
End If

thanks for everyones help! :)
 
herby_one said:
yeah your right, however there are too many street names to place in a combo box.
.


Over 65,000, you must have a lot of landlords on the books :eek:
 

Users who are viewing this thread

Back
Top Bottom