Hello everyone,
I currently have a form that has demographic info like ID, NAME and a search criteria like TASK_ID and LOCATION_ID.
I created a button that would open a matching report based on other participants information matching that on the form TASK_ID and LOCATION_ID. When compiling the code I get a member not found under DO/LOOP myrs.Participant_ID. Can anyone help me debug the following code:
Thanks!!!
Private Sub btnMatch_Click()
On Error Resume Next
Dim mydb As Database, myrs As Recordset
Set mydb = CurrentDb
idlist = ""
Loc_needed = Me![Location].Value
Task_needed = Me![TaskService].Value
If Loc_needed = "" Or IsNull(Loc_needed) Then
Set myrs = mydb.OpenRecordset("qselMatch", dbOpenDynaset)
criteria = "[Participant_ID] Is Not Null"
Else
Set myrs = mydb.OpenRecordset("qselMatch", dbOpenDynaset)
criteria = "[GAvail_Location_ID] = '" & Loc_needed & "'"
End If
myrs.FindFirst criteria
If myrs.NoMatch Then
MsgBox ("No Participants meet your location critera"
Exit Sub
End If
Do Until myrs.NoMatch
idlist = idlist & "'" & myrs.Participant_ID & "',"
myrs.FindNext criteria
Loop
Set myrs = mydb.OpenRecordset("qselMatch", DB_OPEN_DYNASET)
If Task_needed <> "" Then
criteria = "[SAvail_Task_ID] = '" & Task_needed & "' and [Participant_ID] in (" & idlist & "
"
myrs.FindFirst criteria
If myrs.EOF Then
MsgBox ("No Participants meet your Task critera"
Exit Sub
End If
idlist = ""
Do Until myrs.NoMatch
idlist = idlist & "'" & myrs.Participant_ID & "',"
myrs.FindNext criteria
Loop
End If
doreport:
mysql = "[Participant_ID] in (" & idlist & "
"
DoCmd.OpenReport "rptPotentialMatch", A_PREVIEW, , mysql
End Sub
I currently have a form that has demographic info like ID, NAME and a search criteria like TASK_ID and LOCATION_ID.
I created a button that would open a matching report based on other participants information matching that on the form TASK_ID and LOCATION_ID. When compiling the code I get a member not found under DO/LOOP myrs.Participant_ID. Can anyone help me debug the following code:
Thanks!!!
Private Sub btnMatch_Click()
On Error Resume Next
Dim mydb As Database, myrs As Recordset
Set mydb = CurrentDb
idlist = ""
Loc_needed = Me![Location].Value
Task_needed = Me![TaskService].Value
If Loc_needed = "" Or IsNull(Loc_needed) Then
Set myrs = mydb.OpenRecordset("qselMatch", dbOpenDynaset)
criteria = "[Participant_ID] Is Not Null"
Else
Set myrs = mydb.OpenRecordset("qselMatch", dbOpenDynaset)
criteria = "[GAvail_Location_ID] = '" & Loc_needed & "'"
End If
myrs.FindFirst criteria
If myrs.NoMatch Then
MsgBox ("No Participants meet your location critera"
Exit Sub
End If
Do Until myrs.NoMatch
idlist = idlist & "'" & myrs.Participant_ID & "',"
myrs.FindNext criteria
Loop
Set myrs = mydb.OpenRecordset("qselMatch", DB_OPEN_DYNASET)
If Task_needed <> "" Then
criteria = "[SAvail_Task_ID] = '" & Task_needed & "' and [Participant_ID] in (" & idlist & "
myrs.FindFirst criteria
If myrs.EOF Then
MsgBox ("No Participants meet your Task critera"
Exit Sub
End If
idlist = ""
Do Until myrs.NoMatch
idlist = idlist & "'" & myrs.Participant_ID & "',"
myrs.FindNext criteria
Loop
End If
doreport:
mysql = "[Participant_ID] in (" & idlist & "
DoCmd.OpenReport "rptPotentialMatch", A_PREVIEW, , mysql
End Sub