DCount Help

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I want to lookup data in a query based on the CustomerID. When the user
enters a CustomerID in the form I want to use a DCount to go to the query
find the CustomerID that matches and if the Field OnHold = "H". From that I
am going to show a label on the Form that says "Account On Hold".

SID = Me.CustomerID.Value
stLink = "[CustomerID]=" & "'" & SID & "'"

If DCount("CustomerID", "qryARInvoiceSum", stLink, "Hold1") = "H" Then
Me.lblOnHold.Visible = True
End If

Obviously it doesn't work. Can anyone help on my syntax?
 
T

Tom Lake

mattc66 via AccessMonster.com said:
Hi All,

I want to lookup data in a query based on the CustomerID. When the user
enters a CustomerID in the form I want to use a DCount to go to the query
find the CustomerID that matches and if the Field OnHold = "H". From that I
am going to show a label on the Form that says "Account On Hold".

SID = Me.CustomerID.Value
stLink = "[CustomerID]=" & "'" & SID & "'"

If DCount("CustomerID", "qryARInvoiceSum", stLink, "Hold1") = "H" Then
Me.lblOnHold.Visible = True
End If

Obviously it doesn't work. Can anyone help on my syntax?

You need DLookup, not DCount.

If DLookup("OnHold", "qryARInvoiceSum", "[CustomerID] = '" & [custidfield] & "'") =
"H" Then
Me.lblOnHold.Visible = True
End If

Replace custidfield with the name of the textbox on the form into which the user
types the CustomerID
to be matched.

Tom Lake
 
P

PJFry

I looks like you really need a Dlookup instead of a Dcount.

If DLookup("Hold1","qryARInvoiceSum","CustomerID = " & Me.CustomerID) = "H"
Then
Me.lblOnHold.Visible = True
End If

PJ
 
M

mattc66 via AccessMonster.com

Yes - you both are totally correct. Thanks for your help. That worked great..

Tom said:
[quoted text clipped - 11 lines]
Obviously it doesn't work. Can anyone help on my syntax?

You need DLookup, not DCount.

If DLookup("OnHold", "qryARInvoiceSum", "[CustomerID] = '" & [custidfield] & "'") =
"H" Then
Me.lblOnHold.Visible = True
End If

Replace custidfield with the name of the textbox on the form into which the user
types the CustomerID
to be matched.

Tom Lake
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top