adding record on form

F

FubarDave

I want users to input certain data into a new record on a form.

The remaining data I want to complete automatically.
Firstly would I write this code under the Before Insert [Event Procedure]
and if not then where?

Secondly how do I write the code. I have tried Me.Fields![Fieldname].Value =
etc. but it does not work.

Can anyone help ?
 
D

Dorian

Before Insert will work or Before Update if you want it to work when updating
existing records as well.
You just need Me!ControlName = 'value'
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
F

FubarDave

Dorian,

what if it is a field and not a control that I want to enter data for ?
Thanks for the reply,

Dave

Dorian said:
Before Insert will work or Before Update if you want it to work when updating
existing records as well.
You just need Me!ControlName = 'value'
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


FubarDave said:
I want users to input certain data into a new record on a form.

The remaining data I want to complete automatically.
Firstly would I write this code under the Before Insert [Event Procedure]
and if not then where?

Secondly how do I write the code. I have tried Me.Fields![Fieldname].Value =
etc. but it does not work.

Can anyone help ?
 
D

Dorian

On a form, fields (or more properly table columns) are in controls. Each
control is 'bound' to a field. If you want to input data for a field that is
not on the form, you need to create a control to bind it to and then make the
control hidden by setting the visible property to FALSE. You can then set its
value in your code unbeknownst to the user who will never see it.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


FubarDave said:
Dorian,

what if it is a field and not a control that I want to enter data for ?
Thanks for the reply,

Dave

Dorian said:
Before Insert will work or Before Update if you want it to work when updating
existing records as well.
You just need Me!ControlName = 'value'
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


FubarDave said:
I want users to input certain data into a new record on a form.

The remaining data I want to complete automatically.
Firstly would I write this code under the Before Insert [Event Procedure]
and if not then where?

Secondly how do I write the code. I have tried Me.Fields![Fieldname].Value =
etc. but it does not work.

Can anyone help ?
 
Top