Default Values from Previous Record

karatelung

Registered User.
Local time
Today, 10:24
Joined
Apr 5, 2001
Messages
84
I want to make my subform just a little more user-friendly.

When a user hits the "New Record" button, I want the new record in the subform to display the same data as the previous record in the subform on certain fields.

Can someone help me with the code for the "OnClick" property, or is there a better way?

Richie
 
dim db as database
dim rst as recordset
set db=currentdb
set rst=db.openrecordset("underlyingtable",dbopendynaset)
rst.addnew
rst!field1=me!field1
rst!field2=me!field2
rst!field3=me!field3
rst.update
me.bookmark=rst.bookmark

This should work, I may be wrong on the bookmark part. This just makes the form go to the new record, but it's off the top of my head.
 
try
rst=db.openrecordset("tblName") instead of the previous code. This should allow Access to default to the correct recordset type.
 
Charity,

I'm still getting the same error - "run-time error: 314 type mismatch concerning the line:

Code:
Set Rst = db.OpenRecordset("table")

I found this interesting information, ACC2000:"TYPE MISMATCH WHEN COMPARING BOOKMARKS, in the Microsoft Knowledge base, but I still can't solve my problem.

Any more suggestions? From anyone?

Thank you, Charity, and all the other helpful Access developers.
 

Users who are viewing this thread

Back
Top Bottom