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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem w/ the 'DoCmd.OpenReport cmd. 3

Status
Not open for further replies.

jwa6

Programmer
Sep 16, 2002
152
0
0
US

this is pretty straight forward.
I want to open a report based on the same qry as the form. I am using the form filter values ( which work) to open a report / the same record set - which isnt working.

this is the command.

DoCmd.OpenReport "rptqCBoxes_w_Years_exp2", acViewPreview, "", "\OffTypeDesc]=\Forms]!\fCBox_Search2]!\cboOffType] And \FileTypeDesc]=\Forms]!\fCBox_Search2]!\cboFileType]", acNormal

any suggections out there in the ether?
seems that having 2 data fields in the DoCmd.OpenReport cmd. is the issue as i have heard other users having this same issue

thanks

jim
 
Not sure if this is accidental in typing the data into this posting, but the \ characters should be an open square bracket ([). Change that and try again, post your results.

John
 
I noticed that as well

its something w/ this editor that put those in
but thanks for noticing

jim
 
How are ya jwa6 . . .

Thats some editor ya got there!

Try this:
Code:
[blue]   Dim frm As Form, Criteria As String
   
   Set frm = Forms!fCBox_Search2
   
   Criteria = "([OffTypeDesc] = '" & frm!cboOffType & "') And " & _
              "([FileTypeDesc] = '" & frm!cboFileType & "')"

   DoCmd.OpenReport "rptqCBoxes_w_Years_exp2", acViewPreview, , Criteria, acNormal

   Set frm = Nothing
[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
good suggestion


There are now 3 records on the form( filtered) I have copied your code in - fired off the report - but only 2 of the 3 records show. Same results as the code I was trying before

I have heard of others having issues w/ a 2 parm docmd.

thanks for your effort.

jwa
 
If either of those fields have a single quote in the data, you need to change your code. Wherever you have a single quote, replace it with 2 double-quotes:

Criteria = "([OffTypeDesc] = """ & frm!cboOffType & """) And " & _
"([FileTypeDesc] = """ & frm!cboFileType & """)
 
neither have a quote in the field

but thanks
Ill keep this for future reference
Seems using 2 feilds is a no no in Access based on this board and ITtoolbox as well.

Access is a funny beast -- I have problems using the wizards to open a form ( single record) based on a subform.

I was thinking of writing a back end qry - putting =form field in the qry - then another qry based on that and one more = formfield as the report qry
 
jwa6,

If you create a query based on the SQL for this report, and substitute the form values for data on this criteria in the where clause, does it show all 3 records that you would expect when run?

John
 
yes it does show the correct records
 
OK try a slight variation on TheAceMan1's code:

Code:
Dim Criteria As String
      
   Criteria = "([OffTypeDesc] = '" & Forms!fCBox.Form!cboOffType & "') AND " 

   Criteria = Criteria & "([FileTypeDesc] = '" & Forms!fCBox.Form!cboFileType & "')"

   DoCmd.OpenReport "rptqCBoxes_w_Years_exp2", acViewPreview, , Criteria, acNormal

John
 
got it!

thanks john for the code

Dim Criteria As String

Criteria = "([OffTypeDesc] = '" & Forms!fCBox.Form!cboOffType & "') AND "

Criteria = Criteria & "([FileTypeDesc] = '" & Forms!fCBox.Form!cboFileType & "')"

DoCmd.OpenReport "rptqCBoxes_w_Years_exp2", acViewPreview, , Criteria, acNormal

jwa

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top