A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Filter a report based on a Combo Box



 
 
Thread Tools Display Modes
  #1  
Old May 3rd, 2009, 11:35 AM posted to microsoft.public.access.reports
Shiree[_2_]
external usenet poster
 
Posts: 1
Default 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  
Old May 3rd, 2009, 02:08 PM posted to microsoft.public.access.reports
Ken Snell MVP
external usenet poster
 
Posts: 275
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.