ProNetGroup
MIS
Help!!! I have been trying to recall for a while now how to take data from a table, filter it based on the users preferences (build a sql statement based on the inputs of the form), and then run a recordset to filter out what is needed. I have the recordset working fine...i.e. I have it set to show a message box each time it finds a record, but have yet to figure out how to actually pass that value to another form to display the results. Can this be done through a recordset??? I can get it to display the last record it found, but not all of them. Here is the code I have so far (just the recordset part) and the strSQL is a sql statement that was built before the code and works properly:
DoCmd.Close acForm, "frmViewUtilities"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount = 0 Then
MsgBox "No matches found, please try again."
Exit Sub
End If
Do Until rs.EOF
'MsgBox "Utility:" & rs!UtilityName & " County:" & rs!County
Forms![frmViewUtilitiesResults]![txtUtilityName] = rs!UtilityName
Forms![frmViewUtilitiesResults]![txtCounty] = rs!County
Forms![frmViewUtilitiesResults]![txtRegion] = rs!Region
rs.MoveNext
Loop
rs.Close
I have also tried to pass the values other ways, but nothing seems to work, like setting the recordset to the built sql statement.
Does anyone out there have any suggestions for me??? I would greatly appreciate them!!! Thanks!
DoCmd.Close acForm, "frmViewUtilities"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.RecordCount = 0 Then
MsgBox "No matches found, please try again."
Exit Sub
End If
Do Until rs.EOF
'MsgBox "Utility:" & rs!UtilityName & " County:" & rs!County
Forms![frmViewUtilitiesResults]![txtUtilityName] = rs!UtilityName
Forms![frmViewUtilitiesResults]![txtCounty] = rs!County
Forms![frmViewUtilitiesResults]![txtRegion] = rs!Region
rs.MoveNext
Loop
rs.Close
I have also tried to pass the values other ways, but nothing seems to work, like setting the recordset to the built sql statement.
Does anyone out there have any suggestions for me??? I would greatly appreciate them!!! Thanks!