Add new table to existing form

shawnvw

Registered User.
Local time
Today, 11:34
Joined
Sep 15, 2008
Messages
15
LogsTable is accessed through a form. I need to add a combo box that lets me select a record from PaychecksTable, so I can assign a paycheck to that LogsTable record. I also want to see the fields from PaychecksTable on the form too.

This should be easy. Part of my problem is the Combo Wizard. You know the last step, where you're supposed to choose "Remember the value for later use" or "Store that value in this field"? I'm never clear on what that means. Where is the "remembered" value stored, and how do you get it back? Which do I choose in order to select a record from a table?

Thanks in advance for your help!
 
You know the last step, where you're supposed to choose "Remember the value for later use" or "Store that value in this field"? I'm never clear on what that means. Where is the "remembered" value stored, and how do you get it back? Which do I choose in order to select a record from a table?

"Remember the value for later use" means nothing occurs when an item is chosen You can retrieve the information from the bound (first) column using

Me.ComboboxName

where ComboboxName is the actual name of the control.

If the combobox has multiple columns, you can access them using the Column Index, which is zero-based:

YourComboName.Column(0).Value '1st item
YourComboName.Column(1).Value '2nd item
YourComboName.Column(2).Value '3rd item

These can be assigned to textboxes on your form, usually in the combobox's AfterUpdate event

Code:
Private Sub YourComboName_AfterUpdate()
  Me.MyTextBox = YourComboName.Column(0).Value 
End Sub
The value of the first column of the item selected is placed in the control named MyTextBox.

If you select "Store that value in this field" you will be allowed to chose which field to automatically fill in with the value of the item chosen. In essence the field is bound to the combobox. You don't have to use the type of code I gave you above, assuming you're only interested in the first (or only) column of the combobox.

To return a record with the combobox, you do neither of these. If your form is bound to an underlying table/query, when the Wizard first comes up, you wil see a screen that offers you three options, the third option being

Find a record based on the value Is selected in the combobox

This option will set up the combobox's AfetrUpdate code to retrieve the appropriate record.

I thibk I've covered everything you asked. If not, post back.
 
To return a record with the combobox, you do neither of these. If your form is bound to an underlying table/query, when the Wizard first comes up, you wil see a screen that offers you three options, the third option being

Find a record based on the value Is selected in the combobox

This option will set up the combobox's AfetrUpdate code to retrieve the appropriate record.

Okay, that is helpful. However, as you know, the underlying table of the form is LogsTable, and the Wizard only gives me the choice of fields from that table.

How do I add fields from PaychecksTable to the form? And how do I add a ComboBox to select a record from PaychecksTable?
 
the underlying table of the form is LogsTable, and the Wizard only gives me the choice of fields from that table.
If the Wizard only lets you choose fields from the table the form is based on, in the first screen of the Combobox Wizard you've chosen the the third option

Find a record based on the value I selected in the combobox

as mentioned previously, which is used to retrieve a record. Choosing

I want the combobox to look up the values in a table or query.

should allow you to pull fields from any single table or query in your database.

You cannot actually "select" a record, which is to say retrieve as record, from PaychecksTable while in a form based on LogsTable, but you can retrieve any data and all data you need, as was just described, but choosing

I want the combobox to look up the values in a table or query.

and selecting data for the combobox from PaychecksTable.
 
Last edited:
You cannot actually "select" a record, which is to say retrieve as record, from PaychecksTable while in a form based on LogsTable, but you can retrieve any data and all data you need, as was just described, but choosing

I want the combobox to look up the values in a table or query.

and selecting data for the combobox from PaychecksTable.

I was looking for a way to do that and definitively associating a PaychecksTable record with a LogsTable record. Maybe it's not possible. However, I did think of a workaround.

I made a query that combined the two tables -- joined by a "PaychecksID" in each table -- and used the query, instead of either table, as the source for the form. That way all the fields are available. The combo box fills the LogsTable.PaychecksID field, which in turn tells the query which PaychecksTable record to display.
 

Users who are viewing this thread

Back
Top Bottom