Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Report Based Upon criteria selected in Combo boxes

Status
Not open for further replies.

josh2008

Technical User
Feb 28, 2008
36
US
tblTitles
---------
Title_ID (pk)
titleName

tblArtist
---------
Artist_ID (pk)
aritstName

tblComics
---------
Comic_ID (PK)
Publisher_ID (FK)
Artist_ID (FK)
Writer_ID (FK)
Edition
Volume
Purchase Date
Publish Date
Market Value
Description
Attachment (Picture)

Comics (Form)
-------------
titleName (combo Box)
artistName (combo Box)
Submit (cmd button)

My Code
-------
Private Sub Submit_Click()
DoCmd.OpenReport "Comic_List", acViewPreview, ,_ "(tblTitle.TitleName=[Forms]![Comic_List]![titleName]) and_ (tblArtist.artistname=[Forms]![Comic_List]![artistName])"

End Sub
-----------------------------------------------------------
When this is entered and I push the Submit button these pop up:
------------------------------------------------------------
Forms!Comic_List!titleName
(Prompts for the title Name- I enter it)
then
Forms!Comic_List!artistName
(Prompts for the artist name - I enter it)
Then the report is generated with the correct data. This Is the closest I have gotten it to work in the last two weeks
with multiple web searches and forum postings and hours of work with my teacher, so how do i get it to work with out the msg boxes popping up asking for the same criteria that i already have selected in the combo boxes?
 
How would the code read if only one combo box is used to filter? I'm a newby to the code used. This situation is simular to a report I'm trying create.

 
For one numeric field:

DoCmd.OpenReport "Comic_List", acViewPreview, , "[Title_ID]=" & Me![titleName]

Paul
MS Access MVP 2007/2008
 
Thanks, What would the differance be if it was a Text Field?
 
A text field would have to be surrounded by single quotes:

DoCmd.OpenReport "Comic_List", acViewPreview, , "[Title_ID]='" & Me![titleName] & "'"

A date field would need # instead of '.

Paul
MS Access MVP 2007/2008
 
Thanks!, the single quotes always throw me a loop!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top