473,395 Members | 1,637 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,395 software developers and data experts.

How to Insert combo box values into the table

12
Hello Everybody!
I'm newbie here looking for an advice.

I have two combo boxes and 1 txtbox on the main form:
cboGroupName
cboEmployeeName (filtered based on cboGroup selection)
txtEmployeeId. (shows Id of the Employee Name selected in 2nd cbo)
This part works perfect.

I need to populate all those three selected values into the table "tblCompensation" . I've created a subform bound to this table, but can't link it to the frmMain- there are no records yet in the "tblCompensation".

Thanks in advance for your help!
Mar 20 '07 #1
9 5814
NeoPa
32,556 Expert Mod 16PB
You'll need to post how your tables fit together.
MetaData of both tables should do for you.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; Autonumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Mar 21 '07 #2
VictorS
12
Here is my tables info:


tblGroups
Expand|Select|Wrap|Line Numbers
  1. GroupCode;Text;PK
  2. GroupName;Text

tblEmployees
Expand|Select|Wrap|Line Numbers
  1. LastName;Text
  2. FirstName;Text
  3. EmplloyeeId;Text;PK
  4. GroupName;Text;FK

tblCompensation
Expand|Select|Wrap|Line Numbers
  1. id;Autonumber;PK
  2. GroupName;Text
  3. LastName;Text
  4. FirstName;Text
  5. EmployeeId;Text;FK
  6. CompensationType;Text
  7. Comp.Amount;Currency
  8. CompensationDate;Date/Time
tblCompensation has no records now. I need to create a data-entry form for it using two combo boxes I mentioned.

Thanks a lot!
Mar 21 '07 #3
NeoPa
32,556 Expert Mod 16PB
Before I get into the nitty-gritty of the answer, there are a couple of points to make :
  1. Only use a name like [Comp.Amount] for a field if you actively like trouble.
  2. tblEmployees has a field GroupName which should surely be GroupCode instead.
  3. Your database will work more efficiently if you use AutoNumber fields for your PKs. So much of Access's work is done using the PKs and every time it needs to process a whole string rather than a 4-byte number, is slowing the performance.
Mar 22 '07 #4
NeoPa
32,556 Expert Mod 16PB
Another point I noticed while working on the answer is that your [tblCompensation] table should be :
tblCompensation
Expand|Select|Wrap|Line Numbers
  1. ID;Autonumber;PK
  2. EmployeeId;Text;FK
  3. CompType;Text
  4. CompAmount;Currency
  5. CompDate;Date/Time
All the other fields are referenceable via the [EmployeeId] FK.
For consistency, and to avoid confusion and/or errors later, use the abbreviation 'Comp' (or not) throughout.
If you're curious as to why it's a bad idea to store the same data twice in two different locations, check out Normalisation and Table structures.
Mar 22 '07 #5
Denburt
1,356 Expert 1GB
tblGroups
Expand|Select|Wrap|Line Numbers
  1. GroupID:Autonumber
  2. GroupCode;Text;PK
  3. GroupName;Text 
  4.  

tblEmployees
Expand|Select|Wrap|Line Numbers
  1. EmployeeID;Autonumber
  2. GroupID;Number (using lookup tie this into groups)
  3. LastName;Text
  4. FirstName;Text
  5. EmplloyeeId;Text;PK
  6.  


tblCompensation
Expand|Select|Wrap|Line Numbers
  1. Compid;Autonumber
  2. EmployeeId;Number (Tied to Employees)
  3. CompensationType;Text
  4. CompAmount;Currency
  5. CompensationDate;Date/Time 
  6.  
I think your table structuring should look a bit more like this.
Then you can assign relationships between the tables and tie them together in a more efficient fashion.

Using any characters or spaces other than letters in a field name or table name, forms etc. will cause trouble eventually (my experience).

As a note I hate using [ID] as a field name it really lacks meaning if you use EmployeeID or even EmpID you can put it in both tables and the queries will be more likely to recognize it and auto join them for you, although you should set a designated relationship (Tools Relationships).
Oh and the PK FK ? maybe I need another cup of Mud BRB
Mar 22 '07 #6
NeoPa
32,556 Expert Mod 16PB
The first thing you need to do is to set up relationships between these tables in your database. Tools / relationships... takes you to the relevant window. Full referential integrity is a good idea in most cases (I suspect it is in yours).
When that is done, use the Form Wizard to create a Form (with a sub-form) which will automatically link the fields as per the relationship defined.
Let us know how you get on with this and if you come across any problems.
Mar 22 '07 #7
VictorS
12
Thank you very much for your help!
I corrected everything based on NeoPa's suggestions and it does do what I wanted.
Eventually I might have to use a Denburt's way to design these tables.

My real problem is that tblGroups and tblEmployees(EmployeeId was a Text there) are exported from another database to track Compensation. The reason I tried to include GroupId or GroupName in the Compensation is that combination Employee-Group is changing quite a bit every year and managament would like
to see what Group every Employee belong to every year. The other database tracks changes of Employee positions, not groups.
I think I just answered my own question:)

Thanks again!

Victor
Mar 22 '07 #8
NeoPa
32,556 Expert Mod 16PB
Glad to hear you got it working Victor.
The wizards are a really powerful concept in Access. One of their most useful points is that you can learn a great deal if you examine what they have created for you.
BTW Denburt's recommendations were broadly in line with what I'd said in my earlier posts. Expressed a little differently, but worth considering anyway - even if you have got past the first hurdle.
Never waste good advice.
Mar 22 '07 #9
Denburt
1,356 Expert 1GB
Glad you got it going and I understand your point about tracking the employees groups over the years, makes sense.

Nicely done Neo.
Mar 22 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
1
by: SAN CAZIANO | last post by:
how can clear an html SELECT and next insert in it all the elements of an array () I try this but seems doesn't works. function ComboAddArrayValueWithLabel(combo,ArrayLabel,ArrayValue) { ...
2
by: Bill | last post by:
I'm having what seems to me to be an odd problem. Perhaps there is some explanation, but don't know at this point. Basically I have a form that tracks memberships and donations. The main form...
9
by: Hi5 | last post by:
Hi, Any Idea how, I can make an Insert statement to insert data into 6 different tables, that are all holding all data of my database? Is there any example? I would be grateful if you could...
1
by: Arun | last post by:
Hi Group, I was trying to link a combo box with a list control and having some trouble with that. Could anyone please help me with that. Here's the example of the scenario. Combo Box ;-...
2
by: Grub | last post by:
Hi Yall... This is my objective: I want the following snip of code to insert 2 values into table 'Failures'. The first value is based on a string that a user would type into a combo box. If...
2
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
1
by: technocraze | last post by:
Hi guys, I am having trouble resolving this error. Below mentioned is my code and implmentation. MS Acess is my front end and sql server is my backend. What i want to achieve is to be...
2
by: shredder249 | last post by:
Hi, I have an "Add New Records To Table" form. In the header of the form there is a combo box (artistsource) which looks up values from a different table (Artist), the value selected by the user is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
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...
0
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...
0
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...

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.