Send the user a Msg when a query returns a blank form.

T

Testkitt2

I have a DB with a query and the following criteria:
Like "*" & [Enter By Number or Beginning of Description: ] & "*"
This brings up a general ledger code use in our acctg dept.
now if the user types in something no way near a match, the form comes
up blank (no results). How can I use DCount with my query to send the user a
warning msg.
query field name is "GL Code Description"
the queries name is "QryGL"
if DCount "([GL Code Description])","([QryGL])" = 0 Then
Msg.......
Can someone correct this for me.
Thanks
 
D

David Lloyd

The following code uses a textbox (txtInput) on a form and a command button.
The user would put the [Enter By Number or Beginning of Description]
information in the textbox. Please note that the LIKE expression is
enclosed in single quotes. The third parameter of the DCount function is
equivalent to a WHERE clause without the word "WHERE."

Private Sub Command2_Click()
If DCount("[GL Code Description]", "QryGL", "[GL Code Description] LIKE
'*" & txtInput & "*'") = 0 Then
MsgBox "No Match", vbInformation, "Testing"
Else
'Show results here
End If
End Sub

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I have a DB with a query and the following criteria:
Like "*" & [Enter By Number or Beginning of Description: ] & "*"
This brings up a general ledger code use in our acctg dept.
now if the user types in something no way near a match, the form comes
up blank (no results). How can I use DCount with my query to send the user a
warning msg.
query field name is "GL Code Description"
the queries name is "QryGL"
if DCount "([GL Code Description])","([QryGL])" = 0 Then
Msg.......
Can someone correct this for me.
Thanks
 
Top