How to code a Command button to display current form to a report (1 Viewer)

morpheus

Registered User.
Local time
Today, 18:26
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
 
R

Richie

Guest
second part of your question, create query including dates entered and fields you require, add following in criteria Between Date() And DateAdd("y",-30,Date())
Where is the "productID" on your form? and how does it relate to MixID?
 

morpheus

Registered User.
Local time
Today, 18:26
Joined
Jun 15, 2000
Messages
11
Actually there is not a ProductID. The products that I am dealing with are concrete ready mixes, hence the MixID... there IS a ProductID (the products that go into each mix.. kinda like a concrete ingredients list, but that is not important in what i am attempting.)


Thanks for your help.... is there a way that the query criteria can just be coded in VBA?


Thanks again...and i am so glad it is Friday, my brain is getting fried.
 

Karl K

Registered User.
Local time
Today, 18:26
Joined
Feb 2, 2000
Messages
41
If you are going from the form itself,
rather than

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

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

or just "[MixID] = " & me![MixID]
 

Users who are viewing this thread

Top Bottom