Query Using 2 Keys

Feb 28, 2008

I have a database that consists of 7 tables all linked by a school id number. The other tables hold data related to the schools. Another field common to all the related tables is a date field. I could use some direction on how to structure a query that selects data by school and a specific year. The related tables hold data for a number of years and I need to query and report by school for a given year. My main table holds generic school info. The other tables are linked by school_id and have a year field. I have a query that holds all the data - the trick is how to get the data filtered by year. Thanks for getting me started.

View Replies


ADVERTISEMENT

F Keys

Jul 12, 2006

Is it possible to use F keys to call Forms/Queries. I have used the code below and found when i press F7 spell ceck runs:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF7 Then

Dim stDocName As String

stDocName = "qryDepartment1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

End If
End Sub

I have put this code in the keydown on the form.

Do i need to disable the existing F keys duties.

View 4 Replies View Related

Primary Keys

Nov 28, 2005

I was wondering if anyone would be able to help me? I have two tables which can be linked together as they both contain a field called Company Name. However, in one of the tables I want Company Name to become my primary key but this field contains duplicates. How can Isolve this so that I can still link my two tables together?

View 2 Replies View Related

Link Tbl Keys...which Way To Go?

May 13, 2006

Hi Forum,
I'm building a db to track computer and user problems for work, where I double as a Client Support Administrator (IT Guy).
I have these tables: (simplified list)

tblComputers
tblPeople
tblCompAssignment
tblProblems

I'm at a loss as to how to link the 'Problems' table. This is where I'll record trouble tickets reported by users.
Incoming trouble tickets could relate to the Computer or to the User's Network Login.
I thought I might have a field in the problems table for UserName and also one for ComputerID, but this seems problematic. Anyone got any ideas?

View 12 Replies View Related

Foreign Keys

Aug 25, 2006

Hi,

While designing a database, I came up with 3 different foreign keys in one table. I am afraid this is not right!

Is it possible to have this number of FK in one table or does that suggest a design flaw?

Any help will be very much appreciated.
B

View 7 Replies View Related

Help? Security & Hot Keys

Nov 27, 2007

I am trying to secure my database. I only want people to be able to view the forms that I have created, not the underlying tables, queries, etc. When I open the database, I have it set-up so the menu form opens and the database window with all the tables, queries, etc is not viewed. To view the database window, I use the F11 hotkey. In the start-up menu, I found where to turn these specials hotkeys off, but then as the administrator, if I open the database, how do I open the database window? Every time I open the database now, all I get is my form and I can't get the database window to open?!?

View 2 Replies View Related

Composite Keys

Dec 5, 2005

I have recently started a new project, on one of my tables i have a composite key for my primary key. However when i create a relationship using one of the fields in the primary key i can't "enforce referential integrity". Every time i try i get the message "No unique index found for the referenced field of the primary field"

can any one help

Mindy

View 2 Replies View Related

Primary Keys

Jun 26, 2007

I have two tables :

schema with :

schema-id, Autonumber, primary key
name, text

and a table regel :

regel-id, Autonumber
class a, number (lookup from a table)
class b, number (lookup from a table)
schema-id, Long number

they are linked 1:n. A schema can have many regel's.

I want to make a form of schema and have that form contain a subform with regel's in it. The subform can be shown as a datagrid.

Now here's what I do.. I start the form wizard and select both tables. The wizard takes me to creating what I want and it works too. I have a main form schema and a subform with regel's.

Now I have a problem :

The regel fields (class a and class b) can have only three possible values. And I don't want that the combination of these two fields can be the same.

I'v thought about making these two fields the primary keys of regel, but that doesn't work. It works for one record of schema, but when I navigate to a next record of schema, I can't make all combinations of class a and class b over again. It's like I used the combinations in the preceding record of scheme. Then I tried making three fields the primary key, namely class a and class b and regel-id. Didn't work either. What I need is a primary key on the combination of schema-id, class a and class b. But I don't know how to do that.. after all, schema and regel are seperate tables.

I want to be able to make for every schema record all possible combinations for regel records.

How do I do that?

View 7 Replies View Related

Many To Many And Composite Keys

Oct 6, 2007

Many to Many

I have a basic question, I know for a fact that all many to many relationships have to be broken into two one to many relationships using a junction table. However does that mean it is (a must )to have the two foreign key of the parent tables have to be the (primary composite key) of the junction table.

For example, let’s say I have 5 tables that I need to establish many to many relationships between them. Is it correct to establish a junction table with all 5 foreign keys of the parent tables as composite primary key in the junction table to!

Hope the above making sense!!! :confused:

Many thanks :)

View 3 Replies View Related

Saving Keys

Jun 27, 2005

I have a form in which a user uses multiple combo boxes to choose certain items. each item in the combo box has a key attached to it in the table that the form was created from. I would like to save the appropriate key on my form next to the combo box. If this is possible, how do I go about doing this?

Thanks.

View 3 Replies View Related

Using Function Keys

Sep 1, 2004

How can I use function keys to get it to do a constant thing throughout all my forms etc. e.g. to nominate eg "F3" to save data or "F5" to go back a page etc.

View 2 Replies View Related

Composite Keys Possible?

May 13, 2005

Can Access deal with Composite Primary Keys? or will it only let you assign a single attribute key?

If it does allow you to create composite primary keys, how do you go about doing it?

View 1 Replies View Related

Disabled Keys

Dec 17, 2006

Hello,

I have created a log in form in my database and users will enter their name using a combo. Is there a way I can force them to use the mouse and select their name and not type in the data? Basically something that will disables all keys from the keyboard? Thanks.

View 3 Replies View Related

Using Keys From One Table To Another

Mar 21, 2013

I am absolutely new to Access. How do I put the primary key from one table into another table?

View 1 Replies View Related

Changing Primary Keys

May 1, 2005

Hello all,

I am re-working an old database that 'grew up' the wrong way. It is a medical patient database and has 4 main tables. Primary key of main data table is Medical Record number (MR#), a user entered field (I know...). This links to 3 other tables: Diagnoses (indexed by MR# as well, 1-to-1 relationship with main table), Consults (indexed by a compound key of MR# and date, 1 to many relationship), and Procedures (indexed as well by MR# and date; 1 to many as well).

Here is my plan, and I want to know if I'm going to go about it the right way:

I will first delete the relationships between these tables.
I will then give the main table an autonumber field called PatientIndex, and each other table their own autonumber (DiagnosisIndex, ConsultIndex, ProcedureIndex). I will also give each of the other 'daughter' tables a PatientIndex field as well. I will populate the PatientIndex fields of the daughter records with a VBA routine that matches their MR# with the MR# in the main table, and then inserts the corresponding PatientIndex.

Now that each table has no relationships, and has all the right fields, I suspect Access will allow me to change the Keys for each table, and create new relationships, and it should all work cleanly. The goal is to have each table indexed by an autonumber field that is unrelated to user entry, and to link them by the Primary key.

Does this sound like the right approach? As to why do this if it works OK, it's a matter of maintenance. It's simply too buggy as it stands, and it's torturing me. Will my plan work without crashing the db?

View 5 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

Xml Formatting And Handling Of Keys

Jun 29, 2006

When I export my access database to XML I noticed that the XML elements for the table keys contain the key numbers themselves, not the table name (or a chosen field in the table). For an application I am working on, this presents a problem. What I have is:

One table called 'Process' that looks like:

Process instance_idSystem instance IdProcess name
26 24 Two_thread_process


I have another table called "Thread":

Thread _instance_id Process instance_Id Thread instance name
30 26 T1_instance


XML export looks like:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>26</process_instance_id>
<thread_instance_name>T1_instance</thread_instance_name>
</thread_INSTANCE>
</process_INSTANCE>

What I would *like * the XML to look like is:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>two_thread_process</process_instance_id> (**name instead of key here**)
<thread_instance_name>T1_instance</thread_instance_name>
<thread_instance_type>periodic</thread_instance_type>
</thread_INSTANCE>

The access XML export writes out the key values as they appear in the tables. What I would like is for it to put in the ‘process instance name’ instead of the key that points back to the base (process) field.
Any pointers on how I could do this?

Thanks
John

View 3 Replies View Related

Left And Right Arrow Keys

Apr 13, 2007

I would like to have a event for the left and right arrow keys, does anyone know how to do this?

View 4 Replies View Related

Composite Primary Keys

Feb 25, 2005

Is it possible that a composite primary from table A to be a foreign key in table B?
I have two tables: A and B. The A has some personal details such as first name, surname, phone number, etc.
Since no personal ID is given in my project, I am thinking to use first name + surname as the primary key of table A. But when I wanted to make the relationship between A and B (in B I need to use these 2 name fields as the composite primary keys, too) and ticked the option “enforce referential integrity”, an error message prompted out said it could not find the only primary key in table A.

What should I do with this? Or it is impossible to have a composite primary key to be foreign keys (but also primary) in another table?

It will be great if someone could answer this!
Thanks!

View 4 Replies View Related

Multiple Primary Keys

Feb 28, 2005

I made a database that was working fine. It was only after I had finished the database, and data was being entered, that I was informed that the field I designated as the primary key would not work. Origanally, I used 'OffCit' as the single primary key. Now they tell me that one 'OffCit' can be entered several times for different reasons. To solve this, I thought about using autonumbers but have been told, and seen, that this may not be a good idea. So, I am trying to use multiple primary keys. So far I have had no luck. I have attached a screen shot of the tables and relationships. I have 'OffCit', 'AreaofLaw', and 'EffectiveDate' as the primary keys. The same 'OffCit' and 'AreaofLaw' will be used several times in different records. That is the reason for the third primary key. I am wondering if I have set this up right or if there is something I overlooked. Perhaps someone has an idea that may work better. Thanks for any input.

View 5 Replies View Related

Composite Primary Keys

May 5, 2005

I've noticed that the great and the good all seem to recommend not using composite PKs. Does that even go for join tables in the middle of a many-to-many relationship? Not sure I see what's to be gained by adding an ID and making that the PK.

Any comments?

Dave

View 14 Replies View Related

Composite Keys For Table?

May 12, 2005

I need some help with developing a certain aspect of a db. I need to track the equipment list of clinics. The equipment list doesn't really change (it has 5 possible values though each clinic may only have one to all 5 of them). The db is also to track who the manufacturer is.

I was originally going to do a three piece composite key consistenting of the clinic id, the equipment id and the manufacturer id with quantity as the non pk field. Or the other possiblility that I can see is just using an autonumber as the pk with clinic id, equipment id, and manufacturer id as fk's with qty as the non-key field. So what do you think? If you can put in explanation why your suggestion would work, that would be appreciated as I'd like to increase my knowledge base on this stuff.

If I haven't made my problem clear, I'm quite willing to provide more info.

Thanks,

scratch

View 5 Replies View Related

Redundant Foreign Keys?

Jul 8, 2005

More on the lot materials management program.

I have a series of related table:

Builder
Subdivision
Lot Number
Lot Option
Lot Materials Details

The [Lot Materials Details] table is populated by appending data from the [House Type Details] table tree as follows:

Builder
House Type
Elevation
Options Per Elevation
House Type Materials Details

The filtered Option Table in both branches determine which [House Type Materials Details] records get appended to the [Lot Materials Details] table.

The question is:
Is there any advantage, other than simpler queries later on, to adding the primary key from the [House Type Materials Details] table to the [Lot Materials Details] table.

It’s redundant because the [Lot Options Table] contains the [Options Per Elevation] primary key.

Any thoughts?

View 2 Replies View Related

Should I Use Multiple Primary Keys?

Sep 13, 2005

I have the following table:
YieldID |ProductID | Year | Month| Yield

I want to make sure that it is not possible to insert the same date (so, year and month together) twice for each productID. But at the other hand, it should be possible to insert the same date but then for different productIDs. How can I make sure that Access does this? Can I use (multiple) primary keys to enforce this?
Thank you,
Stacey

View 7 Replies View Related

Multiple Primary Keys?

May 21, 2006

Hi

I have tried searching the forums, but couldn't locate any relevant information. I have an assignment at the moment and am meant to have 8 tables in my data base, two of which are 'User' and 'Hardware' which have the following fields:

USER:
UserCode (Primary Key)
UserFirstName
UserLastName
DepartmentCode

HARDWARE:
HardwareCode (Primary Key)
HardwareName
VendorCode
PurchaseDate

Now I am meant to have another table called 'Hardware Config' consisting of the Primary Key fields from the two tables above, and they are both meant to be Primary Keys in this table.

I have been able to make the 'Hardware Config' table, but I don't know how to make more than one Primary Key... any ideas?

Thanks in advance - dragonfly :o

View 13 Replies View Related

Foreign Keys And Tables

Sep 25, 2006

hi
i need to create a table, i've figured out to make LastName the primary key. But im not so sure about the foreign key, and whether it is necessary to put it into the table in order for all my tables to relate? Sorry if this doesn't make much sense.
Also, to clarify.. 3NF primary keys in one table cannot be used in another table??
thanks

View 2 Replies View Related







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