473,395 Members | 1,846 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.

Adding Record to a table from a form using two different tables

1
I have an employee table with a basic data (Key=emp_id). The other table has tool data records. Each tool record has a key (tool_no). I want to use a form where the user selects the emplyee id and tool key from a list and create a new record in a different table. I can not seem to get the data into the new table. Thanks in advance for any suggestions.
May 18 '10 #1
2 2148
Jim Doherty
897 Expert 512MB
@mjws00
You can be clever with this little data model and yet be relatively simple with its appearance. I might just have a little stab at creating this app myself just for fun. The easiest way is to use a main form and subform combined together. In which direction you look at design interface is a matter of choice clearly but this is my contribution as I see this:-

tblTool
Tool_no data type autonumber (Primary key)
ToolCategory datatype text size(50) (foreign key to tblToolCategory)
ToolDescription datatype text size(255)
InputDate datatype datetime default Now()

tblToolCategory
ToolCategory datatype text size(50) (Primary key >linked to tbltool.ToolCategory)
InputDate datatype datetime default Now()

tblToolUseage
UID autonumber (Primary Key)
tool_no datatype Number (Long Integer) (foreign key to tblTool.Tool_no)
emp_id (datatype assumed as Number Long integer but depends on your referencing) (foreign key to tblEmployee.emp_id)
DateOut datatype datetime (no default)
TimeOut datatype datetime (no default)
DateBack datatype datetime (no default)
TimeBack datatype datetime (no default)
InputDate datatype datetime default Now()

There are obvious validation check constraints to be applied to the above table noteably the date fields ie: cannot be back if it has not gone out that type of thing)


tblEmployee
emp_id (Primary key assumed to be autonumber but up to you)
FirstName datatype Text size (50)
Surname datatype Text size (50)
InputDate datatype datetime default Now()

Relationships
a) Create a one to many link between tblToolCategory.ToolCategory field and tblTool.ToolCategory in the relationships window. Set cascade update to yes

b) Create a one to many link between tblTool.Tool_no field and tblToolUseage.Tool_no in the relationships window.

c) Create a one to many link between tblEmployee.emp_id and tblToolUseage.emp_id in the relationships window.

The linkages on b and c to tblToolUseage provide for a many to many relationship. An Employee can have one particular tool many times out conversely a Tool can have been out to a single employee or many employees, but only once obviously at any one time. (I hope I am making myself clear)

1) Create one simple query based on tblCategory save it as qryToolCategory create a tabular form based on that query and save it as frmCategory, design it to your liking. This form services any edits you might want on that datasource.

2) Create one simple query based on tblEmployee save it as qryEmployee create a tabular form based on that query and save it as frmEmployee, design it to your liking. This form services any edits you might want on that datasource.

3) Create one simple query based on tblTool save it as qryTool create a tabular form based on that query and save it as frmTool, design it to your liking. This form services any edits you might want on that datasource. Include in that form a dropdown controlsource of which is ToolCategory and its rowsource set to "SELECT ToolCategory FROM tblToolCategory ORDER BY ToolCategory;" This effectively provides you with the assignment capability for a category set against a particular tool.

4) Now create a query based on tblToolUseage save it as qryToolUseage. This is the main datasource in effect. This is main query of reference where you will be hooking an employee to a tool at any given time.

Now depending on what suits you best in how you work you can design it various ways coming at it from the Employee side or from the Tool side or a bit of both. It depends largely on what it is you are comfortable viewing. For instance if an employee comes to you and says "I want a torque wrench" you can either call up his single record form view main form (ie not tabular) and see his details under which lists a history of his tool useage in a subform located beneath his/her details in descending order latest to the top etc etc. Sitting on this main form could be a Listbox of all Tool Categories alongside which is a list of 'Currently Available' tools that could be selectable sympathetic to the Category you pick on screen. Once an available tool is selected you hit a button to confirm and it 'appends' the displayed tool_no (from the listbox) and displayed emp_id to the tool useage along with the current date and time that tool goes out.

Now obviously this is ONE way of doing it. You might wish however to see by default a list of Available tools only in tabular view and assign an employee to it THAT way it is a matter for you..........but essentially this is how I see the structure of this. The inner workings of the tool availability, the appending of new tool useage and the display of only those tools available together with a list of ALL tools that are currently out and 'not' returned is a matter for development

I trust you can follow the design of this as I see it. Design perspective is a personal thing ultimately but I rather gather that simplicity is the ultimate goal and whilst my post is not particularly simple and concise it is meant to help you in some way..I hope.
May 18 '10 #2
Jim Doherty
897 Expert 512MB
@mjws00
In addition to my last post. I have had a play and put together the 'beginnings' of a little db and attached it to this post It contains a basic layout and some routines you might want to have a look at. It is along the lines of wnat you want to do. Rip it apart.... you might find some useful techniques with listboxes, table additions counting methods and so on in the code module and behind the form.
Attached Files
File Type: zip toolstore.zip (50.7 KB, 114 views)
May 20 '10 #3

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

Similar topics

2
by: Ewin | last post by:
I'm a beginner user of MS Access, and I am having a problem building a database with a complex form that enters to several tables. I did not use subforms because I am attempting to emulate...
7
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables....
2
by: Ron Nolan | last post by:
Re: Access 2000 Does anyone know how to add column to a table using ADO? I need to add a column called "autonum" that has a datatype of "AutoNumber" to a table called "MyTbl". I have searched...
2
by: Tolu | last post by:
Hello I am trying to save information from one form to two tables. I have a table for Student info and Transcript line. I have a form that list all the classes (using text boxes) a student is...
0
by: elmo | last post by:
Hi, I have a transaction table that I need to update from a from. The form should be able to display information from different tables. I have a Learner table with Learner information. I also...
2
by: gary.huntress | last post by:
I'm trying to add a record to a data grid in a pretty standard fasion. I have a dropdownlist in my footertemplate: <FooterTemplate> <asp:DropDownList runat="server" id="newTitle"...
2
by: veenaaecom | last post by:
Hi, I have a table A , table B and table C. Table B is kind of a bridge to table A and table C (i.e it has common columns that bridges table A and table C) I have a colun in table A whose value is...
5
by: Markw | last post by:
Hello Folks, It's your new mysql and php user looking for some more help. Background: I'm attempting to develop an online SCUBA Diving Log application. My plans are to put it together in pieces...
3
by: sudhashekhar30 | last post by:
hi all i am using formview control(asp.net 2.0) 1rst time. don't know much about it. i want to display record in it from different tables at different time. like 1rst time form view is showing...
1
by: Steve | last post by:
This may be a dumb questions please forgive I have a form that shows a list box that links to a table with 7 employee names The form does not show employee key. When adding record to master...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.