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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.Addnew for Autonumber fiield

Status
Not open for further replies.

Vcscwi

Programmer
Jan 15, 2004
57
US
When useing tbl.addnew / tbl.update and you have an autonumber field, how do you give it a value?

For example tbl is the table and it has three fields (fldA, fldB, fldC) FldA is an autonumber field. The code looks like:

tbl.addnew
tbl!fldB = Forms!frmX!txtX
tbl!fldC = Forms!frmY!txtY
tbl.update

When you do an addnew shouldn't it automatically assign the next value to fldA? I'm guessing not because I'm getting an error... so what should tbl!fldA = ?

Thanks
 
Hi, Vcscwi,

I don't believe you can assign a value to an autonumber field, it should automatically be written, I presume, when the .Update method is invoked.

Can you post a little more detail? What error are you getting? Where does the code break? I assume tbl is a recordset object...

Ken S.
 
Thanks for replying... you are correct it does auto fill the autonumber field upon .update.

I misread the error message, it was refering to a linked table where the parent needed a value prior to creating the child.

Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top