coding help

L

Lauren B

I am attempting to write a code so that when a command button is clicked, a
field in the form is automatically populated.

In the "On Click" event procedure, I want to have code that indicates the
following statement be entered into the field "Coverage Area":

ed^<jurisdiction>^ALL

I need the <jurisdiction> part of the statement to automatically be replaced
with the actual jurisdiction of the user. This particular field is located
on another table. The form that contains the command button is actually a
sub form within the larger form that contains the field "jurisdiction."

If everything was on one form, I would use the code:

Coverage Area = "ed^<" & [jurisdiction] & ">^ALL"

however, how can I refered a field (ie. jurisdication) when it is located on
a different table and essentially a different form?

Thank you very much for any assistance.

LB
 
J

John Nurick

Hi Lauren,

You can refer to the value of a control on another open form using this
syntax
Forms("FormName").Controls("ControlName").Value
which can be abbreviated to
Forms!FormName!ControlName

If your code is running in a subform, you can get the value of a control
on the parent form with
Me.Parent.Controls("ControlName").Value

If the the control is in a subform on another form, it's

Forms("FormName").Controls("NameOfSubformControl").Form.Controls("ControlName").Value

Or you can use the DLookup() function to retrieve the value of one field
in a particular record in a table.



I am attempting to write a code so that when a command button is clicked, a
field in the form is automatically populated.

In the "On Click" event procedure, I want to have code that indicates the
following statement be entered into the field "Coverage Area":

ed^<jurisdiction>^ALL

I need the <jurisdiction> part of the statement to automatically be replaced
with the actual jurisdiction of the user. This particular field is located
on another table. The form that contains the command button is actually a
sub form within the larger form that contains the field "jurisdiction."

If everything was on one form, I would use the code:

Coverage Area = "ed^<" & [jurisdiction] & ">^ALL"

however, how can I refered a field (ie. jurisdication) when it is located on
a different table and essentially a different form?

Thank you very much for any assistance.

LB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top