Forum Discussion
ajcbutler1120
May 28, 2021Copper Contributor
Record Count for If Statement if 0
Hi
I have written some code below to count if the SQL query I want to run has any records in it so I can use it in an if statement but can't get it to work.
Dim lRecCount As Long
lRecCount = DCount("autonumber", "Select_Unselected_StockWIP", "(((Estimate_ID) = '" & Me.EstimateNo & "' And (Status)=0)")
MsgBox (lRecCount)
I get this error message:
Does anyone know what I am doing wrong?
Hi,
There is one opening parenthesis too many:
(((Estimate_ID)
has to be
((Estimate_ID)
Or even better, leave out all superfluous parenthesis:
lRecCount = DCount("autonumber", "Select_Unselected_StockWIP", "Estimate_ID = '" & Me!EstimateNo & "' And Status=0")
MsgBox lRecCountServus
Karl
*********
http://AccessDevCon.com
https://www.donkarl.com