The following is a VBA code I am trying to create to set the SQL statement for a query based on on a parameter set from a listbox.
When I run the module, I get an error, "Variable Not Defined". It has the qryPhysician_Registration_Data.Prime_Care_ID highlighted in the strWhere clause.
Any help will be aprreciated.
Thanks
PHP:
If lstSelect.Value = 4 Then
SQL = "SELECT qryPhysician_Registration_Data.Prim_Care_ID, dbo_DMisProvider.Name AS PrimCare_Name"
SQL = SQL & "FROM qryPhysician_Registration_Data INNER JOIN dbo_DMisProvider ON qryPhysician_Registration_Data.Prim_Care_ID = dbo_DMisProvider.ProviderID"
SQL = SQL & "GROUP BY qryPhysician_Registration_Data.Prim_Care_ID, dbo_DMisProvider.Name;"
Else
For i = 0 To lstRight.ListCount - 1
StrIn = StrIn & "'" & lstRight.Column(0, i) & "',"
Next i
If Len(StrIn) = 0 Then
MsgBox "No Physicians Selected!" _
, vbExclamation, "Returning to Selection Screen!"
Exit Sub
End If
strWhere = " WHERE ((" & qryPhysician_Registration_Data.Prim_Care_ID = _
" " & Left(StrIn, Len(StrIn) - 1) & "));"
SQL = "SELECT qryPhysician_Registration_Data.Prim_Care_ID, dbo_DMisProvider.Name AS PrimCare_Name"
SQL = SQL & "FROM qryPhysician_Registration_Data INNER JOIN dbo_DMisProvider ON qryPhysician_Registration_Data.Prim_Care_ID = dbo_DMisProvider.ProviderID"
SQL = SQL & "GROUP BY qryPhysician_Registration_Data.Prim_Care_ID, dbo_DMisProvider.Name"
SQL = SQL & strWhere
End If
When I run the module, I get an error, "Variable Not Defined". It has the qryPhysician_Registration_Data.Prime_Care_ID highlighted in the strWhere clause.
Any help will be aprreciated.
Thanks