DoCmd OpenForm - with WHERE clause not working ? (1 Viewer)

Dragonous24

New member
Local time
Today, 11:50
Joined
Feb 6, 2020
Messages
15
Hi, I'm struggling with this issue also.
I'm trying to open a form using 2 variable where conditions and keep getting type mismatch errors.
Code:
CourseMOD = "[fld_Name_course] = '" & Course & "'"
PersIDMOD = "[fld_PersID_trec] = '" & PersID & "'"
           
strCriteria = CourseMOD & " And " & PersIDMOD
DoCmd.OpenForm "frmTrainingRecord", , , strCriteria
I've also tried
Code:
DoCmd.OpenForm "frmTrainingRecord", , , PersonIDMOD And CourseMOD
which also doesnt work.

I imagine i there are Quotations in the wrong place or something when combine the strings but i've tried a few variations and cant find the solution.

EDIT: Soon after posting this i found my problem.
Solution:
Code:
CourseMOD = "[fld_Name_course] = '" & Course & "'"
PersIDMOD = "[fld_PersID_trec] = " & PersID

strCriteria = CourseMOD & " And " & PersIDMOD
DoCmd.OpenForm "frmTrainingRecord", , , strCriteria
PersID is an integer and didn't need the extra quotes around it.
I feel like such an idiot for not spotting that earlier.
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 03:50
Joined
Aug 30, 2003
Messages
34,242
Thanks for updating the thread, glad you got it sorted.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom