form genrated for some records not for others

G

Guest

i have an access database where i generate forms from individual records.
the database works fine for most records but there are a few records that
when selected the form will not appear. does anybody have any suggestions
on how i should go about finding and correcting the problem.
thank you...
 
R

Rick B

Not sure what you mean by "generating forms from records". A form contains
records. I've created records in a form, but never created a form from a
record.

You would need to tell us exactly what you are doing and what happens in
each case.
 
G

Guest

im sorry if i did not explain myself clearly. here goes another attempt.
i have created a form which i use to monitor lab values for different
people.
when i open the form to a specific patient i have a button set up to create
a second form which is a letter. that letter is populated with the patients
address and info. i then print the form(letter) and mail it to the patient.
i have had no problem with this process and it seems to work for most
patients, but there are a few patients that when selected i cannot generate a
(form)letter.

i hope this is more clear and to the point. thank you.
 
R

Rick B

You don't print forms, you print reports.

Build a report and print it using your button. Reports have the controls
needed to set up proper printing. Forms don't.

As far as why your current process only works for some of them, I could not
tell you. Are you saving the record before pulling up the letter? Could
this be happening because you sometimes add a new patient and try to print
the letter before you have save it? Is your "letter" pulling patient
information from the table, or directly from the fields on your form?


Just FYI,

By default, when you open a report, it will produce the report for all the
records in your query or table. Here is the code yo ucan use to cause your
button to open a report and only show the current record. This code will
take care of saving the record before opening the report.


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



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.
 

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