By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Save from combox bound info to table

P: n/a
rob
I built a combo box that contains names of people. A user can chooses
a person from the combo box, the next couple of the text boxes will
show the corresponding address of that person. I used personnel ID
number to connect the person to his/her address. I want to try and
save the name and address of a person into a table. I used VBA to try
and save the information, but instead of the information being saved
to the table, the ID number that connects the person's name and
his/her address together is saved to the table. Both the name and the
address are in the same table. Can anyone please help me with VB code
involved in saving the correct info into the table?

This is the code I used to get the info from the combo box and the
text box to save into the table

Private Sub Submit_Click()
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("address book", dbOpenDynaset)

rst.AddNew
// table variables | text and combo box variables
rst!Name = Me.Combo6
rst!street = Me.street
rst!city = Me.city
rst!state = Me.state
rst!state = Me.zip
rst.Update

End Sub

-----------------------------------------------------------------------------------------------------------
// Combo box sql code for getting info from table
SELECT [address].ID, [address].[Name] FROM [address];

//Text box sql code for getting corresponding info from same table
SELECT [address].ID, [address].address FROM [address];
SELECT [address].ID, [address].city FROM [address];
SELECT [address].ID, [address].state FROM [address];
SELECT [address].ID, [address].zip FROM [address];
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
See the Column property
Me.Combobox.Column(1)
Columns start at 0. Perhaps your name is cthe 2nd olumn THen you ref column(1).
rob wrote:
I built a combo box that contains names of people. A user can chooses
a person from the combo box, the next couple of the text boxes will
show the corresponding address of that person. I used personnel ID
number to connect the person to his/her address. I want to try and
save the name and address of a person into a table. I used VBA to try
and save the information, but instead of the information being saved
to the table, the ID number that connects the person's name and
his/her address together is saved to the table. Both the name and the
address are in the same table. Can anyone please help me with VB code
involved in saving the correct info into the table?

This is the code I used to get the info from the combo box and the
text box to save into the table

Private Sub Submit_Click()
Dim db As Database
Dim rst As Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("address book", dbOpenDynaset)

rst.AddNew
// table variables | text and combo box variables
rst!Name = Me.Combo6
rst!street = Me.street
rst!city = Me.city
rst!state = Me.state
rst!state = Me.zip
rst.Update

End Sub

-----------------------------------------------------------------------------------------------------------
// Combo box sql code for getting info from table
SELECT [address].ID, [address].[Name] FROM [address];

//Text box sql code for getting corresponding info from same table
SELECT [address].ID, [address].address FROM [address];
SELECT [address].ID, [address].city FROM [address];
SELECT [address].ID, [address].state FROM [address];
SELECT [address].ID, [address].zip FROM [address];


Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.