One last question, what is the syntax of the control source for a Company ID
that is stored in my combo box, yet the text box is on my main form?
You lost me. An ID is not "stored in" a combo box; a combo box is not
a data storage medium, it's a tool which allows you to select data
from one table, display up to ten fields (typically just one though)
and store that field or a different field into another table.
Similarly, a textbox is not a data storage medium, it's another
display tool which displays the value of a table field.
Your data resides IN YOUR TABLES. The Form is just a window!
A Combo Box has several interrelated properties:
- The Row Source is a table, or (more often) a Query selecting one or
more fields from a table. For instance you might have a Query selcting
the CompanyID and the CompanyName.
- The Bound Column selects one of these fields to become the combo
box's value. In this example, you can use 1 as the Bound Column and
the value of the combo box will be the selected CompanyID.
- The Control Source is the name of the field (in the form's
recordsource) into which that CompanyID will be stored. Typically this
will be the CompanyID foreign key field in some table other than the
Company table.
- The ColumnWidths property is a series of numbers separated by
semicolons, indicating the width (in inches or centimeters) of each
field's display. A zero width means "keep this value around but don't
show it to the user" - so you could use a ColumnWidths of
0;1.25
to show the user the company name in a 1.25 inch wide box. The
computer knows about the ID but since it's zero width the user doesn't
see it (and doesn't need to see it!)
I lied,
I have another question, my main form is based on a select query that I want
to add records to; how do I get a blank record to show up instead of the
first record in the table?
Two ways:
- Set the Form's DataEntry property to True. This will let you add
records but not view existing records.
- Or, view the Form's properties; on the Events tab click the ... icon
by the "Open" event. Choose the Code Builder. Edit the result to
something like
Private Sub Form_Open(Cancel as Integer) << Access gives you this
DoCmd.GoToRecord acNewRecord
End Sub << and this
John W. Vinson[MVP]