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

copying a field to a new record

Status
Not open for further replies.

Donzie

Technical User
Jul 10, 2006
2
US
Hi--
In my macro, I figured out how to go to a record (in a form)that I like (Highest # in a series). I want to copy the itemnumber data from that field, add one to it and add a new blank record with that itemnumber+1 already filled in.

Is a macro even the right place to store field data as a variable, add one to it and replace it in a new record, same field?

Thanks, from an old dBase 3+ whiz.

 
I'd say that a macro is not the right thing to be using for anything in any version of Access beyond Version 1

You'll find 'everything' a lot easier in VB code.
It might take a bit more learning in the short term but it is sooooo much more flexible and powerful.
Macros still exist in Access for legacy app support, not to be used for new stuff.

What you need to be doing is :-
Define a variable to keep your number
Dim lngSerial As Long

Set it by going to the record you like and then
lngSerial = controlName ' Where controlName is the name of the control on the form that contains the Serial Number value - This is presumably bound to a field in the underlying table

Then go to the new record and simply
controlName = lngSerial + 1

'ope-that-'elps.





G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top