Senin, 04 Maret 2013

Re: [MS_AccessPros] On Format Event in Report Repeats twice (MS2010)

 

John

As usual I learn a lot from you.

Is I place the database in the Load event then there several conditions in the Print event which adds records in the recordset.
see sample code:

Case "EFT", "CCard"
p1_l4 = " would be $" & eft_bucks_ren & " , making your total draft $" & eft_bucks_tot & " effective as of your " & _

Else 'is CCard
p1_l4 = " would be $" & eft_bucks_ren & ", making your total credit card charge $" & eft_bucks_tot & " effective as of your " & _

End If 'Eft
'----------------------enter record in tblSixYrHold-------------
If Nz(DCount("*", "tblSixYrHold", "MSeqNo=" & Me.MasterFileNo)) = 0 Then
With rstRS
.AddNew
!MseqNo = Me.MasterFileNo
!CollectionMode = Me.CollectionMode
!RollDate = Me.Nextcollectiondate - 5
!RollAmt = Me.Eftgrosscollamt
!PolicyNo = Me.PolicyNo
.Update
.Close
End With
Set dbsDB = Nothing
End If
'----------------------------------------------------------

--- In MS_Access_Professionals@yahoogroups.com, John Viescas wrote:
>
> Norbert-
>
>
>
> When you're at the bottom of a page, and the next detail section won't fit,
> you'll get events in this sequence:
>
>
>
> Format
>
> Retreat
>
> Format
>
> Print
>
>
>
> Why not do this in the Print event that fires only once for each detail
> section?
>
>
>
> Also, why not define the database and recordset at the module level and open
> the recordset in the Load event? And it's more efficient if you do:
>
>
>
> Set rstRS = dbsDB.OpenRecordset(strSQL, dbOpenDynaset, dbAppendOnly)
>
>
>
> . since you're only adding records.
>
>
>
> John Viescas, Author
>
> Microsoft Access 2010 Inside Out
>
> Microsoft Access 2007 Inside Out
>
> Microsoft Access 2003 Inside Out
>
> Building Microsoft Access Applications
>
> SQL Queries for Mere Mortals
>
> http://www.viescas.com/
>
> (Paris, France)
>
>
>
>
>
>
>
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
> drnorbert@...
> Sent: Monday, March 04, 2013 2:05 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] On Format Event in Report Repeats twice (MS2010)
>
>
>
>
>
> Why the event On Format in a Report is duplicating?
>
> I would like to add code to populate a table inside the ON Format Event such
> as for ex:
>
> Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
>
> Dim rstRS As Recordset
> Dim strSQL As String
> Dim dbsDB As Database
>
> Set dbsDB = CurrentDb
>
> strSQL = "SELECT * FROM tblSixYrHold"
> Set rstRS = dbsDB.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
>
> With rstRS
> .AddNew
> !MseqNo=me.MasterFileNo
> .Update
> .Close
> End With
>
> Set dbsDB = Nothing
>
> End Sub
>
> Perhaps I could insert an Static counter to avoid duplication when the
> record is inserted in the recordset.....
>
> Thanks a lot
> Norbert
>
>
>
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar