Dcount, Grrrrrr...... (1 Viewer)

PeterWieland

Registered User.
Local time
Today, 15:51
Joined
Sep 20, 2000
Messages
74
Why is Dcount so damned fussy?

I am trying to display a record count on a sub-form, using criteria from a text box on the parent form. This is what I have:

counter = DCount([ID], "qryReturnUserRecords", "[LessonNo] = Forms!frmGetInputData!txtLesson")

When I run it, I get the following error:

Run-time error '170'

Line 1: Incorrect syntax near '!'

I have checked several examples on here and the line appears to me to be formatted correctly, but I always seem to have problems with the syntax of Dcount. Can anyone enlighten me?

Thanks in advance
 

Bat17

Registered User.
Local time
Today, 15:51
Joined
Sep 24, 2004
Messages
1,687
you need to put the form link outside I think

counter = DCount([ID], "qryReturnUserRecords", "[LessonNo] =" & Forms!frmGetInputData!txtLesson)

Peter
 

KenHigg

Registered User
Local time
Today, 10:51
Joined
Jun 9, 2004
Messages
13,327
If [LessonNo] is a string:

counter = DCount([ID], "qryReturnUserRecords", "[LessonNo] = '" & Forms!frmGetInputData!txtLesson &"'")

If it is an intger:

counter = DCount([ID], "qryReturnUserRecords", "[LessonNo] = " & Forms!frmGetInputData!txtLesson)

I think this is correct.... :D
 

PeterWieland

Registered User.
Local time
Today, 15:51
Joined
Sep 20, 2000
Messages
74
Thanks a lot for the prompt response guys, that did the trick (integer solution).
 

Users who are viewing this thread

Top Bottom