Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

store two records from table A to table B with one entry

Status
Not open for further replies.

Gofaster

Technical User
Apr 23, 2001
13
GB
Hi all

I have two tables call them A + B, I need to store two of the fields from the selected record in table B into table A. (Both fields in table B come from the same record.) I know how to use the combo box but that only lets me save one feild I need to save two and I want to do it with just one entry within the form.
Any ideas??????
 
If you are using a combobox to select a field from a table and want to also include other fields then change your RowSource in the ComboBox to a query of the table and include the other columns of data. Increase your column count, and set the column widths for these new columns to zero. You can now assign the values from the additional rows to textfields on your form that are bound to your table B by the reference to the .Column property of the combobox.

Code:
Me.textfield = Me.ComboBox.Column(1)

The column property begins enumeration of the columns with a reference to 0 thru (N-columns -1).

Post back if you need additional help or explanation.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Bob

yes the conbo is already coming from a querry of table B,

Sorry not used much code, my combo box is number is 16 and the extra row I want is to store is 3.

where do I put the code line?


Ta

ROn
 
The name of the combobox is Combo16? And I believe you mean the exrra column that you want to store is COLUMN 3, yES. What is the name of the form control that you want the data to be moved to?

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Bob
Yes the name of the combobox is combo16
Yes its column 3 I want to store into table A, feild name "time" in table A and B.

Ta

ROn
 
Try this code in the AfterUpdate event procedure of Combobox16:

Code:
Me.[Time] = Me.[Combo16].column(2)

This will take the actual column 3 from the RowSource of the combobox record selected and move it to the control Me.Time on your form which should be a bound control to TableA. Make sure you change the properties of Combo16 to accomodate the data columns of the rowsource: number of columns, column widths, bound column, etc.

Is this what you were looking for?

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Thanks Bob

Got it to work have been off access for a while so a bit rusty. Thanks 4 your help.

ROn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top