DCount Type Mismatch

G

Guest

In the Load event of a form that adds notes to a given project, I want to
check if a record already exists for the given Project
Number/StaffID/NoteDate combination. The values of these three fields are
stored in textboxes on the form from which the Notes form is opened. Since
this can be two different forms, the name of the form is passed using
OpenArgs.

The types of the above fields are Text, Integer, and Date/Time,
respectively. The DCount call below crashes with a Type Mismatch error. I'd
appreciate any help.

If DCount("[ProjectNoteID]", "ProjectNotes", _
"[ProjectNumber]=" & "'" &
Forms(Me.OpenArgs).Controls("txtProjectNumber") & "'" & _
" AND [StaffID] = " & Val(Forms(Me.OpenArgs).Controls("txtStaffID"))
& _
" AND [NoteDate] = " & "#" &
Forms(Me.OpenArgs).Controls("txtPeriodStartDate") & "#" + _
Val(Forms(Me.OpenArgs).Controls("txtDayNumber"))) = 0 Then

.... do stuff

Thank you.
Sprinks
 
G

Guest

G'day Sprinks,

What's the + txtDayNumber at the end meant to be achieving? If you are
wanting to add it to the date, it's in the wrong place, and is almost
certainly what's causing your syntax error.

Damian.
 
G

Guest

Damian,

Thank you; that is the error.

Sprinks

Damian S said:
G'day Sprinks,

What's the + txtDayNumber at the end meant to be achieving? If you are
wanting to add it to the date, it's in the wrong place, and is almost
certainly what's causing your syntax error.

Damian.

Sprinks said:
In the Load event of a form that adds notes to a given project, I want to
check if a record already exists for the given Project
Number/StaffID/NoteDate combination. The values of these three fields are
stored in textboxes on the form from which the Notes form is opened. Since
this can be two different forms, the name of the form is passed using
OpenArgs.

The types of the above fields are Text, Integer, and Date/Time,
respectively. The DCount call below crashes with a Type Mismatch error. I'd
appreciate any help.

If DCount("[ProjectNoteID]", "ProjectNotes", _
"[ProjectNumber]=" & "'" &
Forms(Me.OpenArgs).Controls("txtProjectNumber") & "'" & _
" AND [StaffID] = " & Val(Forms(Me.OpenArgs).Controls("txtStaffID"))
& _
" AND [NoteDate] = " & "#" &
Forms(Me.OpenArgs).Controls("txtPeriodStartDate") & "#" + _
Val(Forms(Me.OpenArgs).Controls("txtDayNumber"))) = 0 Then

.... do stuff

Thank you.
Sprinks
 

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