Connecting Tech Pros Worldwide Forums | Help | Site Map

Primary Key to Equal Foreign Key and Autoupdate

Newbie
 
Join Date: Mar 2007
Posts: 20
#1: Mar 24 '07
I am using access 2000.

I have two questions

Question 1

I have 3 tables. tblFlight, tblAircraftType, tblFlightProgramIN/OUT.

tblFlight has a 1 to many relationship with tblAircraftType, tblFlightProgramIN/OUT.

I have used tblFlight Pk FlightID as the foreign key in tblAircraftType and

tblFlightProgramIN/OUT.

However, I was testing some data and realised that the value of the tblFlight PK FlightID key does not autoupdate to equal the value of the FK FlightID in the tblAircraftType, tblFlightProgramIN/OUT.

Is this correct? Should'nt they have the same value eg tblFlight.FlightID =1(PK)
tblAircraftType.FlightID=1(FK)

Question 2

I am implementing a Global Popup Calendar from the following link.

http://www.fontstuff.com/access/acctut09.htm

However I get an error that says "You entered an expression that has no value".
When I hover the debugger over the value I get an error that says You "cboOriginator.Value has no starting value".
I entered a default value of Date() in the properties section of the cboOriginator.Value(combobox on the form). But I still get the same error.

I entered a test value in the table that links to the combobox but still get the same error.
Before I made the calendar cboOriginator a Global Variable it worked ok.

However I am using a number of comboboxes on the form to pick dates from each day of the week corressponding to arrival and departure dates eg.

Arrival Date:
Monday(cboArrivalDate1) Tuesday(cboArrivalDate2
Departure Date:
Monday(cboArrivalDate1) Tuesday(cboArrivalDate2

The name of my combobox is cboArrivalDate1.Value
Here is the code below.



Here is a the code below

Private Sub cboArrivalDate1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set cboOriginator = cboArrivalDate1
ocxCalendar5.Visible = True
ocxCalendar5.SetFocus
If Not IsNull(cboArrivalDate1) Then
ocxCalendar5.Value = cboArrivalDate1.Value
Else
ocxCalendar5.Value = Date
End If

End Sub

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: Mar 25 '07

re: Primary Key to Equal Foreign Key and Autoupdate


In response to question 1, do you mean that you want it to update the foreign key values if you change the primary key value? To do you you have to set up referential integrity in the relationship between the tables. You can view the relationships from Tools > Relationship.
Reply