How to code a Command button to display current form to a report

morpheus

Registered User.
Local time
Today, 02:14
Joined
Jun 15, 2000
Messages
11
Two part question:
1)I am working on a Quality Control database to store test data on over 1700 different products. Right now I have a form designed that has a set of three tab controls so the end user could switch the three sets of test data subforms that are linked to the main product information, thus displaying just that products data.

I want to add a command button that opens up a report displaying the data information for the product displayed. I have yet to find out how i can do this without having a popup dialog asking me what Product ID I want. I want to be able to eliminate this step and go straight into the report with the currently displayed information.


2) Now once that is accomplished how do I have the report ONLY display and print the last 30 chronological entries by date...NOT the last 30 entered, and sort them in ascending order?

I think i am going gray over here trying to figure it out.

Currently this is the coding that i have:

Private Sub GoToDataCompReport_Click()
On Error GoTo Err_GoToCompReport_Click
DoCmd.OpenReport "rptDataComp", acPreview, , "[MixID]=[Forms]![frmDataComp]![MixID]"

Exit_GoToDataCompReport_Click:
Exit Sub

Err_GoToDataCompReport_Click:
MsgBox Err.Description
Resume Exit_GoToDataCompReport_Click

End Sub
 
Your best bet is to have your sub work off of a double click on one of the products. That way it knows exactly which ProductID is selected and you can then open the report with:

DoCmd.OpenReport "rptDataComp", acPreview, , "[MixID]=[Forms]![frmDataComp]![MixID]"

However, I recommend that you change the last line to:

"[MixID]= " & [Forms]![frmDataComp]![MixID]

It works better for me.
 

Users who are viewing this thread

Back
Top Bottom