I'm wanting to create a report in Access based on the results of the recordset I ran in VBA. Here is the rundown on the necessaries:
The SQL is pulling from a table named “tblINF_Main_Table” based on the data entered into a form named “Inv” with the field “SearchCrit_Store”. The form’s purpose is to allow the user to search for records based on multiple criteria. For this reason, I am hard coding instead of using Access queries. There will eventually be a long list of conditions and keeping up with that many queries would be a hassle. The code does work, but I’m clueless as to how to output the results and create a report on those results.
Function INFsearch()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
strSELECT = "SELECT * FROM tblINF_Main_Table" & " "
If [Forms]![Inv]![SearchCrit_Store] <> "" Then
strWHERE = "WHERE [Store Number] IN" & "(" & [Forms]![Inv]![SearchCrit_Store] & ")"
Else
Exit Function
End If
strSQL = strSELECT & strWHERE
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
Debug.Print rs.Fields("Record Indicator")
rs.MoveNext
Loop
End Function
The SQL is pulling from a table named “tblINF_Main_Table” based on the data entered into a form named “Inv” with the field “SearchCrit_Store”. The form’s purpose is to allow the user to search for records based on multiple criteria. For this reason, I am hard coding instead of using Access queries. There will eventually be a long list of conditions and keeping up with that many queries would be a hassle. The code does work, but I’m clueless as to how to output the results and create a report on those results.
Function INFsearch()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
strSELECT = "SELECT * FROM tblINF_Main_Table" & " "
If [Forms]![Inv]![SearchCrit_Store] <> "" Then
strWHERE = "WHERE [Store Number] IN" & "(" & [Forms]![Inv]![SearchCrit_Store] & ")"
Else
Exit Function
End If
strSQL = strSELECT & strWHERE
Set rs = db.OpenRecordset(strSQL)
Do While Not rs.EOF
Debug.Print rs.Fields("Record Indicator")
rs.MoveNext
Loop
End Function