473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Save from combox bound info to table

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
1 1976
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
1
by: jvb | last post by:
Hello, I have got the following problem. I have an access database with the name of different persons and there telephone numbers. In an access page you can display the field name and the...
4
by: vulcaned | last post by:
Hi All, Hopefully I explain this well........ In Access97 I have a form which has a tab control on it, each tab has a sub-form which is bound to its appropriate table(I'll call them 'Detail'...
2
by: Alpha | last post by:
I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the...
7
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made...
1
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass"....
0
by: Bob | last post by:
I got a 2datagridviews bound to sql serve tables , one parent one child. The changes are always made only to the child table (add, edit or delete) In the Child table definition in SQL server I have...
3
by: KayC | last post by:
Hi Background info: I am running Access 2000 I have a form bound to a blank table When a user clicks a button the form opens in datasheet view User enters data into form and closes form User...
1
by: dewgan | last post by:
I have a form with a combox box where the list is populated via a linked table. This works fine. I have a text box that is filled with the name selected in the combox box. That name is then added...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.