I have a form that displays general information about an alarm permit
location. There's a subform that shows detailed information about
burglar alarms that have gone off at the location. When a new alarm is
entered on the subform, I want to print a report that shows the general
information and the alarms that were entered.
The record source for the form is the Mailing List table (key is Alarm
#).
The record source for the subform is the Alarms table (key is Alarm #,
Entry #).
The link child fields are Alarm #,Alarm Type; and the link master
fields are Alarm #,Burglar.
The record source for the report is a query (Excessive alarms report
merge) based on the Mailing List table.
The record source for the subreport is another query (Excessive burglar
alarms subreport merge) based on the Mailing List table joined to the
Alarms table, with a one to many relationship between Mailing List and
Alarms.
The link child field is Alarm #, and the link master field is Alarm #.
Now after presenting all of my details, here is my problem.
When I enter my new alarm, and try to print the report, the new record
doesn't show up on the report. In messing around with it, after the
report comes up in print preview (without the record), I tried printing
it (from print preview), and the record shows up! I tried changing the
report to print directly without previewing, and the record does not
show up! I have my print code in the after update event of a control
on the subform:
Private Sub Letter___AfterUpdate()
Dim strCriteria As String
Me![Date Sent].Value = Date
strCriteria = "[Alarm #] = " & Me![Alarm #]
If Me![Letter #].Value = 3 Then
DoCmd.OpenReport "rptFalseAlarm3Burglar", acViewPreview, ,
strCriteria
ElseIf Me![Letter #].Value = 4 Then
DoCmd.OpenReport "rptFalseAlarm4Burglar", acViewPreview, ,
strCriteria
ElseIf Me![Letter #].Value = 5 Then
DoCmd.OpenReport "rptFalseAlarm5Burglar", acViewPreview, ,
strCriteria
ElseIf Me![Letter #].Value = 6 Then
DoCmd.OpenReport "rptFalseAlarm6NonResponse", acViewPreview, ,
strCriteria
End If
End Sub
There are other controls on the subform that appear after the Letter #
(Date Sent and Pmt Recvd), but they aren't Tab Stops. The control
seems to go the the form after the Letter # is entered.
I tried moving the open report code to the form after update and form
after insert (on the subform), and the code didn't execute.
I guess I don't understand where in the order of events that the record
actually gets added, but the fact that the record doesn't show on the
print preview, but it does show after I print the preview is totally
freaking me out!
Does anyone have any ideas?