Forms :: Select Recordset ID For Inclusion As Foreign Key In Table

Jun 17, 2014

Trying to use a form based on a table to choose a recordset of values, and pick the ID of that recordset to include in another table as a foreign key.

I am not sure how to even search for what I'm trying to do, though I've tried all the variants I can think of anyway.

The idea being that there are a set of values that are associated with each other, and generally found in conjunction with another set of data. So Table 1 contains data such as this, though this is greatly simplified from the numerics that are actually stored in these fields:

FooID Field 1 Field 2 Field 3 etc, etc...
1 x y z
2 d y z
3 x y q
4 x r P
.
.
.

This data is then associated with the information in table 2, and rather than repeat fields 1-whatever in table 2 I want to use the FooID in table 2 to store the link to all of the subsequent field data. Normalization as I understand it in other words.

I cannot figure out how to pull the table 1 data into a datasheet form and allow someone to choose one of the lines of data, store the FooID into an unbound text box, or some other method, and then run an update query on table 2 to update a field with the FooID for the 12-72 records that are in that table.

Would this make more sense as a combo box in a single form? I've been trying to do this with a datasheet, but I think I'm too limited in appending a check box to an individual recordset this way, or at least I've not managed to get it to work so far anyway.

View Replies


ADVERTISEMENT

Forms :: Primary Key As Multiple Foreign Keys In Single Table

Mar 26, 2013

I'm developing a simple sporting records db. I have a 'Competitor' table listing competitors as follows: CompetitorPK, Name, Division, Club. I have a 'Contest' table listing contests as follows: ContestPK, Competitor1_FK, Competitor2_FK, Winner_FK, Score etc. My question is have I modelled tables correctly i.e. CompetitorPK will appear in three columns of Contest table. How do I define this relationship? What alternative is there to what I have done.I intend to use forms to populate both tables (independantly obviously).

View 4 Replies View Related

Forms :: Export Recordset To A Table

Jun 11, 2013

I have a main form with combo boxes to filter a subform. I want to be able to export the filtered subform data to a table within the database and only include the filtered dataset not all records.

View 14 Replies View Related

Forms :: Cannot Add Records - Join Key Of Table Is Not In Recordset

Nov 25, 2014

Basically, I want to be able to click on the New (blank) record button, and then start adding in my Attraction, Date, etc fields in the main form, however I keep coming up with the error:

Cannot add record(s); join key of table 'OrdersList' is not in recordset.

I've gone back and checked all my relationships, and the query the form is based on, and all appears to be working there fine. I can manually enter information on to the tables & queries just fine, (but obviously I don't want other users to be able to see these).

I'm wondering if it's something to do with the Auto Number, which is also my PK in table 'OrdersList'. As the first design of this database had this field set to a Text field and I would manually enter the next sequence and I didn't have any issues adding new Orders to the form.

The form is 'Orders', which is based on a query called 'Orders List'.

View 12 Replies View Related

Forms :: Cannot Add Records Join Key Of Table Not In Recordset

Apr 14, 2015

I have a form that gets its info from a query, I would like to be able to add a new item, Customer, etc, etc. But, when I try to add one (I have a button using VBA code, ill post that at the end) it gives me the error

Code:
Cannot add record(s); join key or table tblitems not in recordset.

Code:
Private Sub cmdEventNewI_Click()
Me.Visible = False
DoCmd.OpenForm "frmItemsEdit1", acNormal, , , acFormAdd, acDialog
Me.Visible = True
Me.lstItems.Requery
End Sub ' cmdEventNewI_Click

View 8 Replies View Related

Parameter In Select Query Of Recordset?

Jun 25, 2005

hi ,

i want to open a recordset, in its 'where' clause i want to pass the value which i entered in Form textbox? is this possible ?


COde:
rs.open "select * from table1 where id=form.textbox",con

i have written general code above.
when i run my application ..it gives error "Control which is focus can only be reference"
how can i pass my value to select query ?

thanks

View 2 Replies View Related

Forms :: How To Set Recordset Or Count To Determine Existing Record In Table

Dec 28, 2014

I am very new to VBA and I have been self-learning VBA from two month and have been assigned to new project Work Authorization & Lock Out Tag Out.I have table called tblWA & tblLOTO.Basically most of the LOTO/s are associated with WA #, following example

WA # in tblWA
Associated LOTO/s in tblLOTOs
25258
123456
123457
123458
123459
25259
123410
123411
123412
123413

However, both tables are in relationship right now..I have form called WA Switch Board where I have Datasheet View form with all WA records, fields are WA#, WAStatus, WAIssuedDate, IssuedBy, CompletionDate and etc but I have dropdown with with WAStatus with (In Field Today, On-Hold, In Approval, Cancelled, Close).Now from the main switch board when authorized people try to change the status of permit to Closed I want recordset or count to loop through tblLOTO and give me a message box if associated LOTO/s status not equal to Close.In other word, if the associated LOTO/s are not close then the selected WA # in WA Switch Board cant close.Here is the code I have been playing with no success

Private Sub PermitStatus_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb

[code]....

View 3 Replies View Related

General :: Select Specific Dated Recordset

Feb 25, 2014

Set TRANS1 = db.OpenRecordset("SELECT * FROM MASTER WHERE DatePart("yyyy", TRANS1![CDATE]) = " & 2014, dbOpenDynaset)

In the above recordset selection, the ACCESS seems do not allow to have the DATEPART("YYYY") function in the syntax. As CDATE is a table field with date/time data type. Just want to know, how to do this kind of date selection. My purpose is to select all records according to a specific date to the TRANS1 recordset.

View 1 Replies View Related

Two Foreign Keys In One Table.

Apr 20, 2006

I'm not new to access, and I understand normalization at pretty much all its levels, but right now I'm curious about a situation that I have just come across. The first time I've been in something like this, so I thought I would ask.

This is the setup.

I have employees. They are apart of a shift and a budget. Shifts and budgets are completely independent of each other.

The database needs to keep track of shifts and budgets over time. Therefore, 1 to many relationship to shift table and budget table.

But, the database also needs to keep track of attendance. And the user wants attendance tracked by Shift and Budget.

Shift and budget are completely independent of each other.

Currently, I have the relationships set up like this.

Employee (1) ---(Many) Budget (1)------(Many) Attendance
Employee (1) ---(Many) Shift (1)--------(Many) Attendance

When a new attendance record needs to be added, both the key to the budget and shift are added to the attendance table. The key chosen is dependant onthe Employee chosen, and whether the budget and shift are the CURRENT budget and shift that the employee is apart of.

I thought of running a query showing budget and shift by date descending, so that the latest budget / shift would be displayed, and thus the most current (SUPPOSEDLY) But, if a user put in a different date, or screwed up on the date, then the incorrect shift and/or budget would be displayed.

Date stamping an entry was an option, but there needed to also be a user entered date as well, to specify WHEN a user began working in that specific budget / shift. Therefore two date entries would be required. Duplicate entries in most cases.

I therefore decided to go with a true/false yes/no checkbox. Where the current budget or shift would be checked, and all non current ones would be unchecked (false).

Currently, this is how the systems works. And it works well. But it is dependent on some form code I created to set the yes/no checkbox to true/false depending on the situation.

I DON"T like doing this. Am I missing a way to do this "correctly" where by Access would do this "automagically" instead of via my trick.

The ONLY issue really, is that when a new attendance incident occurs, the user needs to put in the incident to the approbriate shift / budget. And if the current shift / budget could automatically be displayed without user intervention (IE user has to pick the shift / budget from drop down box after looking up info etc etc) since the current information SHOULD be known.

I've never done a table setup where two foreign keys are the many side of the relationship in a single table.

It is currently working fine, and seems to do well, but I wanted to make sure with others who might have had this experience. And also, any "advice" / "cautions" for this kind of situation so I don't step into it deep and have to fix it later.

View 14 Replies View Related

Table With Two Foreign Keys?

Oct 5, 2015

Can a table have two foreign keys?

View 1 Replies View Related

Using Foreign Key To Get Related Values From One Table Onto Another Table?

Sep 25, 2013

I created 2 table that are linked to a link table so to get a many to many relationship.I have a table for locations and a table for parts.One location can have many parts and One part can belong to many locations, that is way the many to many relationship.

how to get values from the parts table to the Location table using the linked Primary Key in the foreign key linked field.The values also have to be interactive, if I change the value in the part table it needs to update in the location table.

What can I put in the field of the location table to get a specific value from the parts table?

I tried setting the field to calculated field and put the Dlookup function but that didn't work. The lookup wizard seems to be the solution, but I can only create combobox or list box and I need to select the value manually. I just need a value to be put automatically by looking at the foreign key.

If I put the Dlookup function on the default value, those it update if a value is changed in the part table?

View 3 Replies View Related

Possible For Primary Key Of One Table To Act As Foreign Key In Another Table For More Than One Columns?

Nov 7, 2012

Is it possible for the primary key of one table to act as the foreign key in another table for more than one columns? What I'm trying to do is create a table for a Committee which will have 1 student and 5 professors! So Can I import the faculty ID for each of the 5 faculty members?When I try creating the second relationship, access automatically creates a new Faculty table for the relationship!

View 6 Replies View Related

Forms :: Foreign Key In A Form

Jun 19, 2013

I basically have an Issue's table and a Customer Table relationship set-up.

I want to information to be viewed in the Customer table however I can only see 1 Issue where as a Customer may have 2 or 3 Issues.

I have come up with inserting the whole table into the form however I don't like this look.

View 5 Replies View Related

Link Replication ID As Foreign Key Within Different Table

Oct 2, 2014

How would one link a replication ID as a foreign key within a different table as they aren't numbers and not quite text?!

View 8 Replies View Related

Linked Forms- Foreign Key Update

Apr 30, 2006

Hi,

i need help regarding linked forms..

i have a combo box in a form, where one has to select a country for example UK is chosen, then there is a button that when clicked it opens in a pop-up form and displays all the information related to UK.

so there are two tables : Country (CountryNo : primary key) linked to CountryInfo (CountryNo: foreign key) linked with a one- to -many relationship.

my problem is when you have to add new records to the form CountryInfo, how can i make the foreign key update automatically? thus when adding data to CountryInfo, the CountryNo must be the same to the CountryNo in the CountryTable..

any help will be appreciated thanks a lot.

View 5 Replies View Related

Foreign Key To A Table With Multiple Primary Keyfields???

May 30, 2005

I`m designing a database in MS Access '97.

A lot of the tables I`m using have multiple primary key fields.

How is it posible to create one relationship between 2 fields in table A and 2 primary key fields in table B and force integrity?

thx in advance

View 4 Replies View Related

Forms :: Fill Text Boxes For Same Foreign Key?

Dec 16, 2013

i have build a small project using access 2003 and vba code one of the forms contains sub form the main form contain the main data about school and in sub form populate different > textboxes for details about classes my problem is how to fill these text boxes in this sub >form for different grades depending on id of main form and how can i change the values and >moveing first or next buttons these are simple picture

View 5 Replies View Related

Forms :: Find Count Of Records That Use A Particular Foreign Key

Feb 7, 2014

I wish to be able to count how many times a primary key is being used in another table. In other words:

I have a Game table that lists a set of games by catalogue number, CatalogueNo. I need to create a way to find out how many times that key has been used in a GameCopy table. In the GameCopy table I create a number of stock items (StockNo) using the CatalogueNo from the Game table.

If I can in some way create a query that simple lists each CatalogueNo with its total number of copies that will suffice. I know it is most likely very simple but I just do not know how to implement it within Access without using VBA.

View 8 Replies View Related

One Primary Key In One Table Linked To Two Foreign Keys In Two Different Tables!!!

Sep 22, 2007

Hi there,

I am trying to model my database to create relationships between different tables in my database. During the process of doing so I ended up having one primary key in table A linked with to foreign keys in two different tables ( table B & table C) and both of those two table are junction tables to break out many to many between many other tables

Now for some reason!!! I feel that there is something wrong with my logic mapping and modeling of the relationships between tables due the fact of having one primary key linked to two foreign keys in two different tables :(

Is my intuition is right? should such case be considered as indicative of wrong modeling of relationships between tables in a single database
And if so what is the disadvantages of that link (talking down the road) when the database if fully populated? :confused:

By the way I am new member and new to database, so please take it easy on me :o

Many thanks

View 2 Replies View Related

Tables :: One Primary Key To Multiple Foreign Keys In The Same Table?

Aug 29, 2013

Right now, I have 4 related tables. There's a table with companies, one with people involved with companies, a table linking the two by having foreign keys of the company number and people names, and a table that indicates directors and their alternates.

Since there's a one-to-many relationship for companies/people to company-peopleID (A person can run multiple companies, a company has multiple directors, it's easier this way), a person's name can appear multiple times, as can a company, within that table.

In a company, a director may or may not have 1 and only 1 alternate director to him/herself. So, I thought the easiest way was to put an autonumber in the Company-personID table and have a table (alternates) that had two fields, "alternate" and "director", both using that autonumber to link them. However, it appears as though I can't link the same primary key twice to two foreign keys of the same table.

[URL]

View 3 Replies View Related

Forms :: Auto Complete Form Field With Foreign Key

May 24, 2014

I am trying to auto populate a form from a table containing CustomerID, CustomerName and PCCID_FK

Now in the form I want to auto populate the field cmbPCC when I update the cmbCustomer

using dlookup I've managed to show it manually
=DLookUp("PCCID_FK","tblCustomer","CustomerName='T est'")

It gives the ID of PCCID_FK which is what I want. how do it I modify the expression to replace the TEST part with a value in a combo box.

or is there a better way of accomplishing this.

View 1 Replies View Related

Forms :: Unable To Filter Text In Foreign Key Fields

Mar 8, 2014

In a nutshell, I have a form where the 'Record Source' is a table titled 't_02_0_Assets'. I have several fields in the table that have foreign key references that utilize the Lookup Combo Box display control to allow users to select from a drop down list in the form.

The issue I am having is that I can't filter the text in the foreign key fields (only the ID's ).

My attempted solution was to create a control on the form (text box) and bind it to each of the foreign key ID's using the DLookUp function and then reference this control in the filter code.

My question is... how do I reference this DLookUp textbox in my filter VbCode?

I have attached a '.jpg' image of various aspects of the form including the filter code on the 'On Change' event.

View 1 Replies View Related

Forms :: Select Multiple Records In Subform To Create New Table

May 21, 2013

I need to create some new records based on main form data and a selection of records from a sub form. The main form and sub form have different sources. I wanted to show the source fields in the sub form along with a check box to allow the users to select individual records. The record source for the sub form contains >1000 records, so the user will first enter data in the main form, use filters to find the records he wants to 'assign' to the main form data, click those he selects, then click a command button in the main form to create the record(s) based on the main form data and the selected records from the sub form. The new records will be appended to a new table.

View 6 Replies View Related

Forms :: Using A Lookup Wizard To Select Multiple Entries From A Table

Jul 14, 2015

I am trying to create a lookup wizard to record the number of people who attend a regular event. I have a table recording the names, surnames and DOB of registered members and a number of other tables for regular events we hold. Previously people have been manually adding the names of attendees and of course there have been inconsistencies in the data. I want them to look up the names from the table of registered members. I have been using the lookup wizard, but it is only displaying the first name in a string. I need it to display id, first name, surname and DOB in a table. I also want to be able to type in the first letter and then pick from the list.

View 5 Replies View Related

Forms :: Drop Down Select Control Box - Scrolling Through Records In Table

Aug 14, 2013

I have a fairly large table with approx 15k records. I have a form where I have a drop down/select control box that displays all of these records showing a few of the fields. I select one of these records to create a new record as it places one of the fields into the new record. The problem is that there are so many records that it takes a lot of scrolling to get through all the records.

Once I scroll through all the records, the next time I scroll, it is very fast and shows all the records in one scrolling. However, when I get off the form and then go back it starts over with all the records having to scroll through etc.. What I want to be able to do is have all these records loaded so that they can be scrolled through quickly the first time I open up the form.

View 5 Replies View Related

Forms :: Applying Filter To Subform - Values Stored As Foreign Key

Mar 25, 2013

I am having a problem with a filter that i am trying to apply to a subform.

I have a button on the form that when clicked should filter the subform (which is in datasheet view) to the criteria i set.

This criteria will eventually run from a combo box but I wanted to just get the filter working first.

I put the following code into the onclick event of the button:

Items.Form.Filter = "Items.Form.[Master Category] = 2"
Items.Form.FilterOn = True

I chose the criteria 2 for the filter just as a test as I knew there are some records with that value in the master category field.

The problem is when ever i click the button to apply the filter it clears all the data as if it has not found any records with that value.

Is my syntax and method OK? Why its filtering everything out?

The only other thing to consider is that the field I am filtering on was set up using a lookup wizard linked to a table so the values stored are a foreign key (hence the value being 2 rather than something descriptive).

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved