J
JohnB
Hi.
I posted yesterday about getting some fields to auto populate when a combo
is updated. I've had no replies yet but have now found a similar post which
provided code that I have changed to the following, which works as far as it
goes but I want to modify it.
Private Sub cboSchoolName_AfterUpdate()
On Error GoTo Err_cboSchoolName_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "SchoolID = " & Me!cboSchoolName
' Look up MentorID and assign it to cboMentor.
Me!cboMentor = nz(DLookup("MentorID", "qrySECPlacementsAll", strFilter),0)
Exit_cboSchoolName_AfterUpdate:
Exit Sub
Err_cboSchoolName_AfterUpdate:
MsgBox Err.Description
Resume Exit_cboSchoolName_AfterUpdate
End Sub
The thing is , I want to use a more complicated condition and I've tried
changing the strFilter to the following. I think you'll see what I'm trying
to do:
strFilter = ("SchoolID = " & Me!cboSchoolName) And ("PlacementStage = " &
Me!cboPlacementStage)
I get a type mismatch error when I use this. Am I doing this correctly - is
it a syntax problem? Or is there a better way to do this? I actually want to
have about four "And" conditions built into the DLookup.
Thanks for any help, JohnB
I posted yesterday about getting some fields to auto populate when a combo
is updated. I've had no replies yet but have now found a similar post which
provided code that I have changed to the following, which works as far as it
goes but I want to modify it.
Private Sub cboSchoolName_AfterUpdate()
On Error GoTo Err_cboSchoolName_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "SchoolID = " & Me!cboSchoolName
' Look up MentorID and assign it to cboMentor.
Me!cboMentor = nz(DLookup("MentorID", "qrySECPlacementsAll", strFilter),0)
Exit_cboSchoolName_AfterUpdate:
Exit Sub
Err_cboSchoolName_AfterUpdate:
MsgBox Err.Description
Resume Exit_cboSchoolName_AfterUpdate
End Sub
The thing is , I want to use a more complicated condition and I've tried
changing the strFilter to the following. I think you'll see what I'm trying
to do:
strFilter = ("SchoolID = " & Me!cboSchoolName) And ("PlacementStage = " &
Me!cboPlacementStage)
I get a type mismatch error when I use this. Am I doing this correctly - is
it a syntax problem? Or is there a better way to do this? I actually want to
have about four "And" conditions built into the DLookup.
Thanks for any help, JohnB