I have three tables - Master Address List, Surveyor Details and TblPassportDetails (Names were created before I learned more about databases). Each of these contains different pieces of information about a particular person, with the Master Address List containing details of all the company's contacts (Address, telephone number etc).
The primary key (PK) details in each of the tables are as follows:
Master Address List Record ID
Surveyor Details Alias
TblPassportDetails Alias
I have created two queries - QrySurveyorDetails, which extracts the relevant fields from Surveyor Details and TblPassportDetails, and QrySurveyorDetails2, which combines QrySurveyorDetails with fields from Master Address List.
The two queries are as follows:
QrySurveyorDetails
QrySurveyorDetails2
I have created a form based on QrySurveyorDetails2 in which I can edit a record already created but not add a new record.
I think the problem is with the allocation of Primary Keys and the way the tables are joined but I cannot figure out where I am going wrong. I've read all the relevant threads but I still cannot sort it out.
I would really appreciate a bit of help here.
Best Regards
John
The primary key (PK) details in each of the tables are as follows:
Master Address List Record ID
Surveyor Details Alias
TblPassportDetails Alias
I have created two queries - QrySurveyorDetails, which extracts the relevant fields from Surveyor Details and TblPassportDetails, and QrySurveyorDetails2, which combines QrySurveyorDetails with fields from Master Address List.
The two queries are as follows:
QrySurveyorDetails
Code:
SELECT [Surveyor details].Alias, [Surveyor details].[Surveyor Name], [Surveyor details].Employed, TblPassportDetails.DateOfBirth, TblPassportDetails.PlaceOfBirth, TblPassportDetails.CountyOfBirth, TblPassportDetails.CountryOfBirth, TblPassportDetails.Nationality, TblPassportDetails.P1PassportNo, TblPassportDetails.P1PlaceOfIssue, TblPassportDetails.P1DateOfIssue, TblPassportDetails.P1DateOfExpiry, TblPassportDetails.P2PassportNo, TblPassportDetails.P2PlaceOfIssue, TblPassportDetails.P2DateOfIssue, TblPassportDetails.P2DateOfExpiry, TblPassportDetails.USVisaType, TblPassportDetails.VDateOfIssue, TblPassportDetails.VDateOfExpiry, TblPassportDetails.VPlaceOfIssue, TblPassportDetails.DischargeBookNo, TblPassportDetails.DBDateOfIssue, TblPassportDetails.DBPlaceOfIssue, TblPassportDetails.Height, TblPassportDetails.EyeColour, TblPassportDetails.Sex, TblPassportDetails.UKDL, TblPassportDetails.USDL, TblPassportDetails.Notes
FROM TblPassportDetails RIGHT JOIN [Surveyor details] ON TblPassportDetails.Alias = [Surveyor details].Alias;
QrySurveyorDetails2
Code:
SELECT QrySurveyorDetails.Alias, QrySurveyorDetails.[Surveyor Name], QrySurveyorDetails.Employed, QrySurveyorDetails.DateOfBirth, QrySurveyorDetails.PlaceOfBirth, QrySurveyorDetails.CountyOfBirth, QrySurveyorDetails.CountryOfBirth, QrySurveyorDetails.Nationality, QrySurveyorDetails.P1PassportNo, QrySurveyorDetails.P1PlaceOfIssue, QrySurveyorDetails.P1DateOfIssue, QrySurveyorDetails.P1DateOfExpiry, QrySurveyorDetails.P2PassportNo, QrySurveyorDetails.P2PlaceOfIssue, QrySurveyorDetails.P2DateOfIssue, QrySurveyorDetails.P2DateOfExpiry, QrySurveyorDetails.USVisaType, QrySurveyorDetails.VDateOfIssue, QrySurveyorDetails.VDateOfExpiry, QrySurveyorDetails.VPlaceOfIssue, QrySurveyorDetails.DischargeBookNo, QrySurveyorDetails.DBDateOfIssue, QrySurveyorDetails.DBPlaceOfIssue, QrySurveyorDetails.Height, QrySurveyorDetails.EyeColour, QrySurveyorDetails.Sex, QrySurveyorDetails.UKDL, QrySurveyorDetails.USDL, QrySurveyorDetails.Notes, [Master Address List].Category, [Master Address List].[Contact First Name], [Master Address List].[Contact Second Name], [Master Address List].[Contact Third Name], [Master Address List].[Contact Surname], [Master Address List].Position, [Master Address List].[Mobile Telephone], [Master Address List].[Email Address], [Master Address List].[Home Address 1], [Master Address List].[Home Address 2], [Master Address List].[Home Address 3], [Master Address List].[Home Address 4], [Master Address List].[Town (Home)], [Master Address List].[County+Zip/Post Code (Home)], [Master Address List].[Country (Home)], [Master Address List].[Home Telephone], [Master Address List].[Home Fax], [Master Address List].[Partner's Name]
FROM QrySurveyorDetails LEFT JOIN [Master Address List] ON QrySurveyorDetails.Alias = [Master Address List].Alias;
I have created a form based on QrySurveyorDetails2 in which I can edit a record already created but not add a new record.
I think the problem is with the allocation of Primary Keys and the way the tables are joined but I cannot figure out where I am going wrong. I've read all the relevant threads but I still cannot sort it out.
I would really appreciate a bit of help here.
Best Regards
John