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

Form direcly to Report

Status
Not open for further replies.

LHWC

Technical User
Apr 29, 2004
52
US
I have a form that records information to produce a transmittal cover letter. After data entry I would like a command button to save the record to a table and open a report populated with the current info, ready for printing.
I have a parameter query that asks for Date and Project. I've tried code on the cmd button to save the record, then set the Date and Project fields of the query to the text boxes of the same form fields. Then it should open the report whose data source is the query.
Unfortunately, my code returns type mismatch error.
Am I going about this correctly, or is there simpler way?
Thanks in advance.
 
Surround date values by # and string values by '

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV,
Still getting an error. Here's my code. Not sure if I'm using the correct method. The record does save but the report doesn't open.

Private Sub Preview_Click()
On Error GoTo Err_Preview_Click

Dim stDocName As String
Dim db As Database
Set db = CurrentDb

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

db.QueryDefs("Parameter Query").Fields("Date").Value = Me.Date.[#Value#]
db.QueryDefs("Parameter Query").Fields("Project").Value = Me.Project.['Value']

stDocName = "Transmittal"
DoCmd.OpenReport stDocName, acPreview


Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
MsgBox Err.Description
Resume Exit_Preview_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top