473,803 Members | 2,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OpenRecordse t("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 1999
See the Column property
Me.Combobox.Col umn(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.OpenRecordse t("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
2300
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 has 55, then I want Rulings to have a number greater than 55. Two or more Hearings may be entered before a Ruling is entered. For example, Hearings with CaseIDs= 55, 56, and 57 may be entered before a Ruling or vice versa. There is no definite...
1
1676
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 telephone number. What i want to do is a combobox in wich you can select the name and the the right telephonenumber has to be shown! I CANT FIGURE IT OUT HOW TO DO THIS. IT LOOKS SIMPLE BUT ........
4
2967
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' tables). I have a 'Header' table and fields from it are displayed on the form above the tab control. Header table name is tblClientInfo Detail tables are tblPolicyInfo, tblBeneInfo, tblRiderInfo
2
1969
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 dataset table. Now when I change the selection in the lstSchItem the comboxes are staying the same and not reflecting the changes. I tried changing the binding to the dataview.table but the comboxes are still not changing to reflect the...
7
2839
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 of custom, extended nodes, which include all the extra information contained in the table and not just typical TreeNode objects. To do that, I first created a structure with all the extra
1
3626
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". Each combobox has its datasource, displaymember and SelectedValue member bound to separate tables thru individual datatsets thru individual data adapters. The two tables are "Class" and "SubClass". I use parameterized query to populate the...
0
892
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 an automatic generation via trigger of the date record is modified and the user name of the modifier. When I hit the dataset.Update code My saves are done OK, all the info is there when I look at it in sql server, but I do not see the...
3
6198
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 clicks button which then creates an inner join between form bound table and master table and updates records in master table where values are equal to form bound table
1
1426
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 to another table. That works fine. My problem is this, I want to keep the second table from being populated with the same name. So, for exampe, if I select the name John Smith in the Combo box but John Smith already exist in the second table, I...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10309
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.