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

Sort of a Form to Report Question.

Status
Not open for further replies.

jabrony76

Technical User
Apr 23, 2001
125
US
Hi all,
I have a form in which there is a command button which will open a report that summarizes what has been entered on the form, sort of a "Face Sheet", I call it a "Pseudo Tracker". When I click on the "Print Tracker" button I am prompted to enter the "CMM ID#" (which is one of the fields obviously). Is there a way that I can open this report with using the current record (CMM ID #) that is open in the form? Below I am going to paste the generic code that my command button uses to open the report. Please Help if you can!!

I'm using Access 97 and am not good at code so if you can help me out with some advice or maybe even pasting my code and correcting it so I can past it back in would be awesome but please tell me what I have left out... Trying hard to learn VB!

Thanks!!
Andy

Code is below this line:

Private Sub Command53_Click()
On Error GoTo Err_Command53_Click

Dim stDocName As String

stDocName = "Pseudo Tracker"
DoCmd.OpenReport stDocName, acPreview

Exit_Command53_Click:
Exit Sub

Err_Command53_Click:
MsgBox Err.Description
Resume Exit_Command53_Click

End Sub
 
Change the DoCmd line to this:

DoCmd.OpenReport stDocName, acPreview, ,[CMM ID#]= Me.NameOfCMMID#ControlOnYourForm

That should do it, just remember to reference the proper control name from your form. Joe Miller
joe.miller@flotech.net
 
Joe,
Thanks for the help and I think I understand the logic behind that but my follow up questions is "what does the control name look like? I have tried to enter this code and use:
Me.CMM_ID_#
Me.CMM ID #
Me.Forms!Admission Table!CMM ID #
and the dropdown box that it gives me when I enter Me.CMM_ID__

with the first three entries there was a popup box that told me there was a syntax error. When I used the forth (the dropdown) it continued to prompt me to enter the CMM ID # to open the record. I'm not sure if i was referencing the correct control name or not. Please help again!!
thanks,
Andy
 
Look up the OpenReport Action (the action is similar to the Method, but has the detailed descriptions of the criteria which the method does not, in help for a more detailed description, but this is an excerpt from that passage:


To open a report and restrict its records to those specified by the value of a control on a form, use the following expression:

[fieldname] = Forms![formname]![controlname on form]

The fieldname argument is the name of a field in the underlying table or query of the report you want to open. The controlname on form argument is the name of the control on the form that contains the value you want records in the report to match.

Note The maximum length of the Where condition argument is 256 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenReport method of the DoCmd object in Visual Basic instead. You can enter SQL WHERE clause statements of up to 32,768 characters in Visual Basic.


Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top