Copying a previous field's value and pasting it to a later field

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a database that imports a text file to a table.
The file has a numeric 4-digit code in the title that
needs to be associated with the information below it.

I can get the 4-digit code and place it in a field. I can
identify wether the field has a numeric value or not. I
can assign a value to the field if it is null or not
numeric. What I can't seem to get right is having the
module remember the numeric code and pass it to the next
field.

There is no set number of records.

So the sequence I need is:

Copy and remember the code

Paste the code to the code's following records

Stop when the new code is found

Copy and remember the new code

Paste the new code to the new codes records

This action will continue through the end of the file.

Thanks for your help,

Mike
 
Create a public variable.

At the top of a standard module (not a form's module):

dim strMyCode as string

then in your sub, set your 4 digit code to to it:
strMyCode = WhereEverYouGetYourString

the string will be available to any other calls, (on later records)
untill you set to something else or to Null (or VB errors)

hth,
BLM
 
Thanks,

Worked like a charm.

Mike
-----Original Message-----

Create a public variable.

At the top of a standard module (not a form's module):

dim strMyCode as string

then in your sub, set your 4 digit code to to it:
strMyCode = WhereEverYouGetYourString

the string will be available to any other calls, (on later records)
untill you set to something else or to Null (or VB errors)

.
 
Back
Top