Post info to a report from the current form.

S

Sailor

I am trying to write info from a trouble call (tc)
database, when the user enters their tc I want the info
they enter to show on a report that opens up after
clicking the submit button, this will be their
confirmation page. I only want that one record to show.
How can I accomplish this?

I already have the form and report built, I just have to
put them together.

Thank you,
Sailor
 
M

Marshall Barton

Sailor said:
I am trying to write info from a trouble call (tc)
database, when the user enters their tc I want the info
they enter to show on a report that opens up after
clicking the submit button, this will be their
confirmation page. I only want that one record to show.
How can I accomplish this?

I already have the form and report built, I just have to
put them together.

Part of the code behind the Submit button would consist of a
few lines to print the report. If you'll create a new
button, you can use the button wizard to generate the code
to print the report. Then you can view the code to see how
that is done and modify it to print just the one tc. The
end result will be something along these lines:

Sub cmdSubmit_Click( . . .
Dim strDoc As String
Dim strWhere As String

' First, save any new/changed data
If Me.Dirty Then Me.Dirty = False

' Now print the report
strDoc = "nameofreport"
strWhere = "tcIDfield = " & tcIDtextbox
DoCmd.OpenReport strDoc, acViewPreview, , strWhere
End Sub

Be sure to use your own names for the report, the tc ID
field in the table and its related text box textbox on the
form.
 
S

Sailor

Marsh,

Here is what I have come up with can you tell me if this
correct?

Private Sub Command49_Click()
On Error GoTo Err_Command49_Click

Dim stDocName As String
Dim strWhere As String

If Me.Dirty Then Me.Dirty = False

stDocName = "rpt_RDivConfirmation"
strWhere = "tcID = " & ID
DoCmd.OpenReport stDocName, acNormal

Exit_Command49_Click:
Exit Sub

Err_Command49_Click:
MsgBox Err.Description
Resume Exit_Command49_Click

End Sub


Thanks for your help...

Sailor
 
M

Marshall Barton

Sailor said:
Here is what I have come up with can you tell me if this
correct?

Private Sub Command49_Click()
On Error GoTo Err_Command49_Click

Dim stDocName As String
Dim strWhere As String

If Me.Dirty Then Me.Dirty = False

stDocName = "rpt_RDivConfirmation"
strWhere = "tcID = " & ID
DoCmd.OpenReport stDocName, acNormal

Exit_Command49_Click:
Exit Sub

Err_Command49_Click:
MsgBox Err.Description
Resume Exit_Command49_Click

End Sub

You forgot to specify the WhereCondition argument to
OpenReport:

DoCmd.OpenReport stDocName, acNormal, , strWhere

You're the one that will have to confirm the name of the
field and the name of the text box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top