Supressing a query

Hudson40

New member
Local time
Today, 14:10
Joined
Mar 1, 2007
Messages
8
Hi

I have a query that uses 2 variables from a form. All the query is doing is checking whether the 2 variables exist in a table. 99% of the time there will not be a match. Does anybody know how you supress the query from being displayed when no results are found?

Thanks

Andrew
 
Before you run the query, use DCount() to do the same search. If the count is 0, don't run the query.
 
Suppressing Query

Hi

Thanks for reply and bear with me as I haven't used access for over a year.

Tried the following code:

Dim vInvNo As Variant
Dim VPayee As Variant
Dim Count1 As Long
Dim Count2 As Long

vInvNo = [Forms]![frmInvoiceInput]![Text60].Value
VPayee = Me.[Combo52].Value

Count1 = DCount("Amount", "tblInvoices", "Payee = vPayee")
Count2 = DCount("Amount", "tblInvoices", "Invoice No(s) = vInvNo")

If Count1 > 0 And Count2 > 0 Then
DoCmd.OpenQuery "qryInvoiceCheck"
End If


Basically I'm having probs with the "Payee = vPayee" part in count1 ie how do you include variable in the function?

Cheers

Andrew
 

Users who are viewing this thread

Back
Top Bottom