By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,639 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,639 IT Pros & Developers. It's quick & easy.

Problem getting new record from subform to appear on subreport

P: n/a
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?

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I figured out what was keeping my form after update event from
happening, and when I put my code there, my report prints perfectly.
Now my problem is trying to get the part that was messing up my event
sequence to work again.
In my Letter # control, on the Lost Focus event, a macro was being
executed (I inherited this code). The macro contains a PrintOut Action
(with Selection for the Print Range). This did a perfect "screen
print" of the form with the subform and everything. It also changed
the focus so that my form after update event wasn't firing. It appears
that if I don't execute the PrintOut from a control on the subform, I
end up getting the print out for all of the records in my file, but if
I do execute the PrintOut from a control on the subform, I don't get to
my form after update event. Any ideas now???

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.