Link to home
Start Free TrialLog in
Avatar of TOPIO
TOPIOFlag for United States of America

asked on

Dlookup Query with two variables

I'm trying to do a Dlookup with two variables so that the record brought back from the
query qryAssignation will only be the records 1 to 8 in courseID and GroupID equal to value stored in the cbgroup Combo box but I do not seem to be able to get it to work.
Private Sub cbGroup_AfterUpdate()
Dim i As Integer
'i get the error here
For i = 1 To 8
  Me("lCourse" & i).Caption = Nz(DLookup("Course", "qryAssignation", (("CourseID=" & i) And "GroupID" = Me.cbGroup)))
Next
 
For i = 1 To 8
  Me("lTeacher" & i).Caption = Nz(DLookup("Teacher", "tblteacher", "TeacherID=" & i))
Next
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That assumes both CourseID and GroupID are numeric ... are they?

mx
Avatar of TOPIO

ASKER

Thanks!