If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Filter a report based on a Combo Box
This is the last bit I need to finish a DB - its driving me mad.
I have a report - that I want to filter based on the record of the form. It works perfectly fine for the unique ID Field [Asset Number] But for the field that uses a combo box, I keep getting Error, please please help! Report is called R_Asset. Field to match on is called [Sub Precinct] If I swap the field name to [Asset number] this works perfectly =================== The code is: Private Sub RunReport2_Click() Dim strDocName As String Dim strWhere As String strDocName = "R_Asset" strWhere = "[sub precinct]=" & Me.[Sub precinct] DoCmd.OpenReport strDocName, acPreview, , strWhere End Sub |
#2
|
|||
|
|||
Filter a report based on a Combo Box
I'm guessing that your Me.[Sub precinct] field is a text value, so use this
(I'm delimiting the value with ' characters): Private Sub RunReport2_Click() Dim strDocName As String Dim strWhere As String strDocName = "R_Asset" strWhere = "[sub precinct]='" & Me.[Sub precinct] & "'" DoCmd.OpenReport strDocName, acPreview, , strWhere End Sub -- Ken Snell MS ACCESS MVP http://www.accessmvp.com/KDSnell/ "Shiree" u51649@uwe wrote in message news:958550f2c0e34@uwe... This is the last bit I need to finish a DB - its driving me mad. I have a report - that I want to filter based on the record of the form. It works perfectly fine for the unique ID Field [Asset Number] But for the field that uses a combo box, I keep getting Error, please please help! Report is called R_Asset. Field to match on is called [Sub Precinct] If I swap the field name to [Asset number] this works perfectly =================== The code is: Private Sub RunReport2_Click() Dim strDocName As String Dim strWhere As String strDocName = "R_Asset" strWhere = "[sub precinct]=" & Me.[Sub precinct] DoCmd.OpenReport strDocName, acPreview, , strWhere End Sub |
Thread Tools | |
Display Modes | |
|
|