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

Not clear some fields for New record? 1

Status
Not open for further replies.

Wrecker

Technical User
Aug 29, 2001
126
US
Is there a way to keep the data that is in a selected few textboxes after pushing New record Button? Currently all the textboxes are cleared. I would like a few of them to keep the data from the previous record.

Thanks
Wrecker
 
To do this you need to generate variables for the fields you wish to keep and then add them back after you make the new record, the code would be similar to this;
Dim field1 as string
Dim field2 as string ... for as many as you need!
field1 = Me.txtBox1
field2 = Me.txtBox2 ... storing the fields
Docmd.GoToRecord,, acNewRec
Me.txtBox1 = field1
Me.txtBox2 = field2 ... restoring the values
Me.txtBox3.SetFocus
 
Right. And you'll have to get rid of Access's built in navigation buttons or set AllowAdditions to false and create a command button that users will have to use to add records.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
You can also write the field values in the fields default property so when you append new records, the value is used without a lot of coding.

e.g.:

Name.default=Me.Name

Patrick.
 
Patrick,

I've never played with that method, but if it works, it's pretty darn slick. Thanks.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
You're welcome.

Please give me a star. I'm new and collecting them.

Patrick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top