Copy previous record, VBA

Takstein

Registered User.
Local time
Today, 02:45
Joined
Jan 31, 2007
Messages
54
Hi All

I have a form with a subform where we enter new cable references. Most of the time the new record that you put in will be a duplicate of the previous record + 1(on the primary key/cable reference).

What i wish to make is a small vba action that simply copies the previous values from the record above (if it exists and maybe only if there is no values in the field when you enter...)

I have programmed VB a bit but are all new to the syntax in access. Does anybody have a some code for this? or other example code in the same area?


hope somebody can help!

regards,

Takstein
 
Search the forum for there are plenty of threads discussing your question. ;-)
 
Hi All

I have a form with a subform where we enter new cable references. Most of the time the new record that you put in will be a duplicate of the previous record + 1(on the primary key/cable reference).

What i wish to make is a small vba action that simply copies the previous values from the record above (if it exists and maybe only if there is no values in the field when you enter...)

I have programmed VB a bit but are all new to the syntax in access. Does anybody have a some code for this? or other example code in the same area?


hope somebody can help!

regards,

Takstein


In access when using the command button wizard there is an option that will duplicate the record you are on, if you create the duplicate you can then look behind the code and reset any additional field to "" once clicked.

It is fairly straight forward.
 
In access when using the command button wizard there is an option that will duplicate the record you are on, if you create the duplicate you can then look behind the code and reset any additional field to "" once clicked.

It is fairly straight forward.

Thanks for the tip!
 
What I use to copy fields from one record to a new record within the "Add Button" is the field name default value as below...works great:)

HQIDCombo.DefaultValue = """" & Me.HQIDCombo.Value & """"
WingIDCombo.DefaultValue = """" & Me.WingIDCombo.Value & """"
GrpIDCombo.DefaultValue = """" & Me.GrpIDCombo.Value & """"
SquadronIDCombo.DefaultValue = """" & Me.SquadronIDCombo.Value & """"
FlightIDCombo.DefaultValue = """" & Me.FlightIDCombo.Value & """"
SectionIDCombo.DefaultValue = """" & Me.SectionIDCombo.Value & """"
 
In access when using the command button wizard there is an option that will duplicate the record you are on, if you create the duplicate you can then look behind the code and reset any additional field to "" once clicked.

It is fairly straight forward.

But is there a fairly straight forward way to copy the subform & recordset along with it?
 
You should be able to do the same for the subform as for the main form all you need to do is reference the subform controls.

So you would look to use the me. reference and you should then get the suform name up.

like

me.subformname.controlname.defualtvalue
 

Users who are viewing this thread

Back
Top Bottom