assigning value to record field

ineloquucius

Registered User.
Local time
Today, 03:14
Joined
Jun 6, 2006
Messages
13
If, for example, I wanted to click a button and have its event code (not macro) assign the value "7" to the "customer number" field of the current record how would I do this? I've tried using the syntax created in the expression builder, but to no avail. I'm using Access 2000.

Thanks.
 
Re: my question below

If this question doesn't make sense or is in the wrong location please advise.
 
Is the button on a form? Is there a text box on the form for the fieldd?
 
Yes, and yes

Naturally the greater goal is slightly more complicated, but I'm trying to understand how to reference fields when assigning a value to them in VB code within Access. So yes, there is a button on the form which, when pressed, I would like to assign the number, say, "7" to the field "customer number" which has a textbox bound to it also on the form.
 
A much simpler way to put it...

The greater goal is to:

1) copy a value from a textbox in form1
2) press a button to open form2
3) GoTo the "new" record
4) set the "CustomerID" field to the value copied above in form1

That's it, except that it has to happen in code, not a macro. Preferably more elegantly than using DoCmd.DoMenuItem, as well.

Thanks.
 
in the Event handling functions you can refer to a form's text box value many different ways so long as its open. The most common are:

Forms("Form Name").txtBoxName.Value
or
Forms![Form Name]![txtBoxName].Value
 
In the buttons on click event in form1 use some code like this.

Dim strCust as string

strCust=Me.[TextBoxName].Value

docmd.openForm "[FormName]"

Me.[CustomerId]=strCust
 

Users who are viewing this thread

Back
Top Bottom