Extra Record Being Created

D

Dymondjack

I'm really drawing blanks on this one... thanks in advance.

I'm trying to set up a log table of all changes that are made to certain
fields in the database.

I've got a form that's being updated through code and for some reason the
update is happening twice instead of only once (the first new record has all
the data, the second new record only has data for 1 field).

Tables:
tblOrdHdr 'Main form
RtblOrdHdr 'Revision Table for Main Form


Forms:
frmOrdHdr
UfRevOrdHdr 'A utility form that gets called through code only

Modules:
modUtilsOH

Each field that is being recorded has a few public vars that get changed
after an update to toggle the RevLogging

On the Form_AfterUpdate event for frmOrdHdr is this:

*****
Call subOHRevLog(ctlOHID, rCustSts, rCustPrev, rCustAft, rBillSts,
rBillPrev, _
rBillAft, rShpSts, rShpPrev, rShpAft, rCurRev)
*****

(Passes values for OrderID, Customer BillTo and ShipTo, if they've been
updated and what the before and after values of the update were).

In modUtilsOH is subOHRevLog, which takes any updated values, writes them to
the UfRevOrdHdr new record (including the OrderID and OrderRev). It also
adds +1 to the main form's Order Rev field.

*****
Public Sub subOHRevLog(arID, arCS, arCP, arCA, arBS, arBP, arBA, arSS, arSP, _
arSA, arRev)

'This sub will archive any changes made in the data

If arCS And arBS And arSS = False Then
Exit Sub
Else
DoCmd.OpenForm ("UfRevOrdHdr")

DoCmd.GoToRecord , , acNewRec
Forms!UfRevOrdHdr!ctlOHIDRec = arID
Forms!UfRevOrdHdr!ctlOHNewRev = arRev + 1

If arCS = True Then
Forms!UfRevOrdHdr!ctlCustPrev = arCP
Forms!UfRevOrdHdr!ctlCustAft = arCA
Forms!UfRevOrdHdr!ctlCustModDt = Now()
End If
If arBS = True Then
Forms!UfRevOrdHdr!ctlBillPrev = arBP
Forms!UfRevOrdHdr!ctlBillAft = arBA
Forms!UfRevOrdHdr!ctlBillModDt = Now()
End If
If arSS = True Then
Forms!UfRevOrdHdr!ctlShpPrev = arSP
Forms!UfRevOrdHdr!ctlShpAft = arSA
Forms!UfRevOrdHdr!ctlShpModDt = Now()
End If
DoCmd.Close

Forms!frmOrdHdr!ctlOHRev = Forms!frmOrdHdr!ctlOHRev + 1
DoCmd.Save
End If

End Sub

*****

The problem I'm having with this is that when the RevTable updates with a
new record instead of only doing it once it does it twice, the second time
only entering a rev level thats +1 from what it should be. I've stepped
through all the code, but can't seem to find the point at which it makes it's
second update, and cannot figure out how to stop it from doing it.

Sorry about the long post... trying to lay everything out with all the
required info. Any help is greatly appreciated, as always.

-Jack
 

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