auto enter data in a field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think I have had too much time off over the festive period and am having a
problem getting my head round the easy stuff!!

I have a form which has a combo field called "locations". Each location is
part of a locality. I have a table listing the location code, the location
name and which locality it is attatched to. I want the locality to display in
the locality field on the form when the location is chosen.
How do I go about this?
 
Hi, Lynn.

Be careful to distinguish between a *field*, that has a datatype and is
where data is stored in a table, and *controls*, which display data on a form
and may or may not be bound to an underlying field.

When I first read your subject line, I was afraid you wanted to store a
redundant value, which you don't need nor want to. But it seems you only
wish to display it. Either base the form on a query that contains the fields
you wish to display, or include the field in the Row Source of the combo box,
and set the ControlSource of a textbox using the Column property of the combo
box, referring to the column #, starting with 0. So to display the 3rd
column, set the Control Source to:

=Me!YourComboBox.Column(2)

Hope that helps.
Sprinks
 
Hi, I have a similar problem. I used your formula and I changed the 2 to a
1 to get the second column but I do not get the other information. It stays
as #Name?

If it matters, When I have tried to add tables to the forms query,
everything goes haywire. I get a blank form. Please help.
 
m, you have provided very little information. I will refer to the example in
the original posting. Just to review, right click the combo box and click
Properties. Click Row Source, then click the three dots. You should see a
query design grid containing (in order)the LocationCode (the Primary Key
field), Location, and Locality. If you don't see these as the leftmost
fields, you can make changes here. Still in the combo box's property sheet,
verify that the column count is 3, the bound column is 1, and the column
widths are 0;1.5";0" (the 1.5" can be whatever you need). This will cause
Location only to be displayed in the combo box. Verify the name of the
combo box (not its underlying field).
Back to the code Spinks provided, make sure YourComboBox is the exact name
you saw in the combo box's property sheet. Note that the code will be place
in an unbound text box elsewhere on the form.
Now, it could matter that everything goes haywire when you attempt to add
tables to the form's query, but in order for folks here to investigate that
you will need to provide more information about your database's structure and
purpose.
 
I have carried out your instructions and got so far., but when I try to put
the 'Me' statement in the control source of the text box I get the following
message:

The object doesnt contain the Automation object 'Me.'

You tried to run a visual basic procedure to set a property or method for an
object. However the component doesnt make the property or method available
for automation operations.

Check the components documentation for information on the properties and
methods it makes available for Automation operations.

Have I understood your instructions properly? I created an unbound text box,
and put the statement in to the controlsource of this text box. If so, why
am I getting this error message? and it displays on the form as #Name
 
Try putting square brackets around the name of the combo box only (not the
Column(2) part).
 
gave this a try, but Access keeps puting them back as soon as I click off the
control source box. FYI after removing all brackets this is what access
recreates:
=[Me]![locationcombo].[column](1)
 
Back
Top