printing a report from a form

UCLA Lorna

Registered User.
Local time
Today, 10:39
Joined
Mar 8, 2005
Messages
32
I have a form that shows individual patient data. I want be able print out a mailing label for the current record shown on the form. I tried adding a command button the printed my mailing label (report), but the report needs to be linked to a data source and it prints out labels for all the patients in my database rather than just the one viewed on the form. Thanks.
 
Thanks! That worked great. What if I want to filter based on 2 conditions rather than just one? I tried modifying it but am getting an error.
 
Should be no problem. What do you have so far?
 
DoCmd.OpenForm "SecondFormName", , , "LastName = '" & Me.LastName & "'" & "FirstName = '" & Me.FirstName & "'"

Adding a second condition this way doesn't work. I tried several different versions of this, none successful.
 
Try

DoCmd.OpenForm "SecondFormName", , , "LastName = '" & Me.LastName & "' AND FirstName = '" & Me.FirstName & "'"
 
names with single quotes or hyphens

My search function works great, except for names with a single quote (O'Connor) or with a hypen (Smith-Doe). How can I fix this?
 
Assuming the line of code you presented above is what you're working with, just replace every apostrophy (') with 2 double quotes ("").

So, Paul's code above was:
Code:
DoCmd.OpenForm "SecondFormName", , , "LastName = '" & Me.LastName & "' AND FirstName = '" & Me.FirstName & "'"

Change that to:
Code:
DoCmd.OpenForm "SecondFormName", , , "LastName = """ & Me.LastName & """ AND FirstName = """ & Me.FirstName & """"
 

Users who are viewing this thread

Back
Top Bottom