Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record fails to add when first in table

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
0
0
US
When I add a child record to an existing parent, I use a separate form which I prepare by creating a series of globals that hold the data to be transferred into the child. Some of this goes against good data normalization, but it's necessary for this app.

When I open the child edit form, existing data transfers perfectly. I can edit existing child records or add new ones. But when the parent record is new and no previous child records exist, the globals holding the data to transfer are properly initialized, but the assignments fail, without generating an error. There is WAY too much prep code to list all, but this is what I think is relevant:

Code:
dim mCnum, mTrans_typ, mSeq
dim AddMode as String

' setup for transfer
    mCnum = me.cnum
    mTrans_typ = me.trans_typ
    mSeq = me.seq
    addMode="AddNew"
    DoCmd.OpenForm "frmAddTrans", acNormal, , cnum = theClaim, acFormAdd, acDialog         


Then in frmAddTrans as part of Current, I call

If Addmode = "AddNew" then
    call AddRec
etc.

Sub Addrec

    DoCmd.GoToRecord , , acNewRec   
' now copy in static data
    Me.cnum = mCnum
    Me.trans_typ = mTrans_typ
    Me.seq = nxtSeq

When the parent is a new record (but has been saved in parent table) but there are no already existing children, the assignment fails:
me.cnum=Null, but mCnum=2437466
Me.trans_typ=Null, mTrans_typ="NEW"
Me.seq=Null, mSeq=1

When there already are records in the child table, the assignments work:

me.cnum=2437466, and mCnum=2437466
Me.trans_typ="NEW", mTrans_typ="NEW"
Me.seq=2, mSeq=2

I'm stuck. Anybody have an idea why this happens?

David 'Dasher' Kempton
The Soundsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top