Forms to Reports

  • Thread starter Thread starter nevyn100
  • Start date Start date
N

nevyn100

Guest
What wou,ld be the easiest way to get a form to print preview a report and ONLY show the information from the form I was working on? (in other words... just the information I put in.. not the entire table)
 
I usually add a command button to my form and let the Wizard build the Open Report code then I modify the code to add the linking criteria. For example, if UniqueID is the field that links the info on your form to your report you could add a line to the open report code like:

Dim stLinkCriteria
stLinkCriteria = "[UniqueID]=" & me.UniqueID (if it's a number),
OR
stLinkCriteria = "[UniqueID]='" & Me.UniqueID & "'" (if it's a string).

then add stLinkCriteria to the DoCmd Line for the Where Condition Value. The whole code might look like this:


Private Sub cmdProfile_Click()
On Error GoTo Err_cmdProfile_Click

Dim stDocName As String
Dim stLinkCriteria

stDocName = "YourReport"
stLinkCriteria = "[UniqueID]=" & Me.UniqueID
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_cmdProfile_Click:
Exit Sub

Err_cmdProfile_Click:
MsgBox Err.Description
Resume Exit_cmdProfile_Click

End Sub

HTH
Carmen
 

Users who are viewing this thread

Back
Top Bottom