Using Allen Browns print report from form record selection

  • Thread starter Thread starter ryan.fitzpatrick3
  • Start date Start date
R

ryan.fitzpatrick3

I was reading on Allen Brown's website about printing a report from a
form record selection. I have a question regarding this. I have a main
form that has 3 subforms, which are all linked back to the main form.
How do I 1) create a form to incorporate all of this data and 2) how
do I change this code that is on his page to reflect this, or do I
have to change it?

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

thanks in advance

Ryan
 
You create a report with the data linked together same as on the form, like
from a query. All his code does is save the dirty record if unsaved
changes, prompt to select record if not on good record and then opens the
report using the specific record key.
 
Is there a website that would show an example of a report that pulls
multiple subform information?


You create a report with the data linked together same as on the form, like
from a query. All his code does is save the dirty record if unsaved
changes, prompt to select record if not on good record and then opens the

I was reading on Allen Brown's website about printing a report from a
form record selection. I have a question regarding this. I have a main
form that has 3 subforms, which are all linked back to the main form.
How do I 1) create a form to incorporate all of this data and 2) how
do I change this code that is on his page to reflect this, or do I
have to change it?
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
thanks in advance
 
Reports don't come from forms, they as well as your form comes from a
table(s) You must duplicate the form data using a query based on the same
data as what is being shown on the form. Build a report that uses this
query and lay out the report however you want it. The section strWhere =
"[ID] = " & Me.[ID] is the pointer to the specific record information in the
query that matches your form record pointer. So if the field on the master
form [CustomerNumber] then you would replace both [ID] with that.

Is there a website that would show an example of a report that pulls
multiple subform information?


You create a report with the data linked together same as on the form,
like
from a query. All his code does is save the dirty record if unsaved
changes, prompt to select record if not on good record and then opens the
report using the specific record key.<[email protected]>
wrote in message

I was reading on Allen Brown's website about printing a report from a
form record selection. I have a question regarding this. I have a main
form that has 3 subforms, which are all linked back to the main form.
How do I 1) create a form to incorporate all of this data and 2) how
do I change this code that is on his page to reflect this, or do I
have to change it?
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
thanks in advance
 
Back
Top