Call a report from a form

  • Thread starter Naba via AccessMonster.com
  • Start date
N

Naba via AccessMonster.com

Hi all,

Can anyone help me, i needed to programme a form to open a report. For
instance, if type in a existing item, then it should ask weather i want to
edit the existing record or not and then if i say no, it should ask weather I
want to view the report on the existing Record.

If anyone can help please reply ASAP!!!!!!!
 
A

Arvin Meyer [MVP]

If you type in an existing bound form, you automatically add or edit a
record. The following code would be written in the click event of a command
button. It is entirely air code (untested):

Sub cmdMyButton_Click()
If MsgBox("Do you want to view the report?", vbYesNo, "View it?") = vbYes
Then
DoCmd.OpenReport "Your Report Name", acViewPreview,,"RecordID =" &
Me.txtID
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
N

Naba via AccessMonster.com

Hi,

Thanks for your help Arvin, just made a small change to the coding,

Sub cmdMyButton_Click()
If MsgBox("Do you want to view the report?", vbYesNo, "View it?") = vbYes
Then
DoCmd.OpenReport "Your Report Name", acViewPreview, , "RecordID =" &
txtID
End If
End Sub

Thanks alot Arvin,
If you type in an existing bound form, you automatically add or edit a
record. The following code would be written in the click event of a command
button. It is entirely air code (untested):

Sub cmdMyButton_Click()
If MsgBox("Do you want to view the report?", vbYesNo, "View it?") = vbYes
Then
DoCmd.OpenReport "Your Report Name", acViewPreview,,"RecordID =" &
Me.txtID
End If
End Sub
[quoted text clipped - 5 lines]
If anyone can help please reply ASAP!!!!!!!
 
Top