I am having trouble with a query I have been building in query builder.
I thought query builder was the solution because my search formula has a lot of options to chose from to do the search.
I have been searching to find others with a similar problem and has discovered that Access 2013 is more touchy when it comes to reserved words (so I have been through my entire database and removed any words that could be problematic) and that query builder should be able to handle 255 columns of data - my query is only 75 columns long when the problem shows. And I need the query to have at least 2 columns more for the query to be complete.
The query is an append
query which gather my data in a single table before I export it to excel.
The query builder's SQL is quite long and I think maybe too complex for its own good
Here are the code from query builders SQL view:
INSERT INTO
tblResultsGeneral ( ReGRecordNumber, ReGUVNumber, ReGDate, RefNoInformer, ReGFullName, ReGOfficielObserver, ReGCountry, ReGProvince, ReGMuncipality, ReGNearestTown, ReGAreaName, ReGPathNumber, ReGSCALP, ReGValidateYes, ReGFieldTripYes, ReGScatYes, ReGPreyYes, ReGOtherDNAYes, ReGSightingYes, ReGTrackYes, ReGHowlYes, ReGUrinBloodYes, ReGCameraYes, ReGDenYes, ReGInsideWolfZone, ReGSampleType, ReGSampleEvidence, ReGDogPresent, ReGGELat, ReGGELong, ReGCoordinates, RefNoCoorSys, ReGUTMQuadrant, ReGUTMCoorX, ReGUTMCoorY, ReGPrecision, RefNoValidate, ReGSenckLabID, ReGSenckType_mtDNA, ReGSenckHaploType, ReGSenckInfo_mtDNA, ReGSenckType_NucleusDNA, ReGSenckInfo_NucleusDNA, ReGNumberOfAnimalsCam, ReGNumberOfAnimalsSight, ReGFullNameWriterCam, ReGFullNameWriterSight, ReGFullNameWriterHowl, ReGFullNameWriterOther, ReGFullNameWriterPrey, ReGFullNameWriterScat, ReGFullNameWriterTrack, ReGFullNameWriterUrinBlood, ReGFullNameWriterDen, RefNoValidateSpecies, ReGValidateGenus, ReGValidateSpecies, ReGValidateDanishName, ReGPackName, ReGIndividual, ReGIndiSex, ReGIndiBornYear, ReGIndiBornPlace, ReGIndiDead, ReGIndiDeadCause, ReGProbIndiGuess, ReGIndiAgeAtSampleTime, ReGTerritoryName, ReGMonitoringYear, ReGPhotoNotes, ReGPermissionToUsePhotoText, ReGPhotoFiles )
SELECT
tblRecord.RecRecordNumber,
tblUVNumber.UVNo,
tblRecord.RecDate,
tblRecord.RefNoInformer,
tblPersons.PerFullName,
tblPersons.PerOfficielObserver,
tblLocation.LocCountry,
tblLocation.LocProvince,
tblLocation.LocMuncipality,
tblLocation.LocNearestTown,
tblLocation.LocAreaName,
tblFieldTrip.FiTPathNumber,
tblValidate.ValSCALP,
tblRecord.RecValidateYes,
tblRecord.RecFieldTripYes,
tblRecord.RecScatYes,
tblRecord.RecPreyYes,
tblRecord.RecOtherDNAYes,
tblRecord.RecSightingYes,
tblRecord.RecTrackYes,
tblRecord.RecHowlYes,
tblRecord.RecUrinBloodYes,
tblRecord.RecCameraYes,
tblRecord.RecDenYes,
tblValidate.ValInsideWolfZone,
tblRecord.RecSampleType,
tblRecord.RecSampleEvidence,
tblRecord.RecDogPresent,
tblRecord.RecGELat,
tblRecord.RecGELong,
tblRecord.RecCoordinates,
tblRecord.RefNoCoorSys,
tblRecord.RecUTMQuadrant,
tblRecord.RecUTMCoorX,
tblRecord.RecUTMCoorY,
tblLocPrecision.LocationPrecision,
tblRecord.RefNoValidate,
tblValidate.ValSenckLabID,
tblValidate.ValSenckType_mtDNA,
tblValidate.ValSenckHaploType,
tblValidate.ValSenckInfo_mtDNA,
tblValidate.ValSenckType_KernDNA,
tblValidate.ValSenckInfo_KernDNA,
tblAnimal_1.AniNumberOfAnimals,
tblAnimal.AniNumberOfAnimals,
tblPersons_1.PerFullName,
tblPersons_2.PerFullName,
tblPersons_3.PerFullName,
tblPersons_4.PerFullName,
tblPersons_5.PerFullName,
tblPersons_6.PerFullName,
tblPersons_7.PerFullName,
tblPersons_8.PerFullName,
tblPersons_9.PerFullName,
tblValidate.RefNoValSpecies,
tblValidateSpecies.ValSpeGenus,
tblValidateSpecies.ValSpeSpecies,
tblValidateSpecies.ValSpeDanishName,
tblPack.PackName,
tblIndividual.Individual,
tblIndividual.IndiSex,
tblIndividual.IndiBornYear,
tblIndividual.IndiBornPlace,
tblIndividual.IndiDead,
tblIndividual.IndiDeadCause,
tblValidate.RefNoProbIndiGuess,
tblValidate.ValIndiAgeAtSampleTime,
tblTerritoryName.TerritoryName,
tblMonitoringYear.MonYear,
tblPhotoDoc.PhDPhotoNotes,
tblPhotoDoc.PhDPermissionToUsePhotoText,
tblPhotoDoc.PhDPhotoFiles
FROM
(
tblDen
INNER JOIN
(
tblIndividual
INNER JOIN
(
(tblValidateSpecies
INNER JOIN
(
tblPack
INNER JOIN
tblValidate
ON tblPack.KeyPack = tblValidate.RefNoPack
)
ON tblValidateSpecies.KeyValidateSpecies = tblValidate.RefNoValSpecies)
INNER JOIN
(
tblUVNumber
INNER JOIN
(
(tblPersons AS tblPersons_8
INNER JOIN
tblUrinBlood
ON tblPersons_8.KeyPersons = tblUrinBlood.RefNoWriterUrinBlood)
INNER JOIN
(
(tblPersons AS tblPersons_7
INNER JOIN
tblTrack
ON tblPersons_7.KeyPersons = tblTrack.RefNoWriterTrack)
INNER JOIN
(
tblTerritoryName
INNER JOIN
(
(tblAnimal
INNER JOIN
(
tblPersons AS tblPersons_2
INNER JOIN
tblSighting
ON tblPersons_2.KeyPersons = tblSighting.RefNoWriterSight
)
ON tblAnimal.KeyAnimal = tblSighting.RefNoAnimal)
INNER JOIN
(
(tblPersons AS tblPersons_6
INNER JOIN
tblScat
ON tblPersons_6.KeyPersons = tblScat.RefNoWriterScat)
INNER JOIN
(
(tblPersons AS tblPersons_5
INNER JOIN
tblPrey
ON tblPersons_5.KeyPersons = tblPrey.RefNoWriterPrey)
INNER JOIN
(
tblPhotoDoc
INNER JOIN
(
tblPersons
INNER JOIN
(
(tblPersons AS tblPersons_4
INNER JOIN
tblOtherDNA
ON tblPersons_4.KeyPersons = tblOtherDNA.RefNoWriterOther)
INNER JOIN
(
tblMonitoringYear
INNER JOIN
(
tblLocPrecision
INNER JOIN
(
tblLocation
INNER JOIN
(
(tblPersons AS tblPersons_3
INNER JOIN
tblHowl
ON tblPersons_3.KeyPersons = tblHowl.RefNoWriterHowl)
INNER JOIN
(
tblFieldTrip
INNER JOIN
(
(tblAnimal AS tblAnimal_1
INNER JOIN
(
tblPersons AS tblPersons_1
INNER JOIN
tblCamera
ON tblPersons_1.KeyPersons = tblCamera.RefNoWriterCam
)
ON tblAnimal_1.KeyAnimal = tblCamera.RefNoAnimal)
INNER JOIN
tblRecord
ON tblCamera.KeyCamera = tblRecord.RefNoCamera
)
ON tblFieldTrip.KeyFieldTrip = tblRecord.RefNoFieldTrip
)
ON tblHowl.KeyHowl = tblRecord.RefNoHowl
)
ON tblLocation.KeyLocation = tblRecord.RefNoLocation
)
ON tblLocPrecision.KeyLocPrecision = tblRecord.RefNoPrecision
)
ON tblMonitoringYear.KeyMonYear = tblRecord.RefNoMonYear
)
ON tblOtherDNA.KeyOtherDNA = tblRecord.RefNoOtherDNA
)
ON tblPersons.KeyPersons = tblRecord.RefNoInformer
)
ON tblPhotoDoc.KeyPhoto = tblRecord.RefNoPhotoDoc
)
ON tblPrey.KeyPrey = tblRecord.RefNoPrey
)
ON tblScat.KeyScat = tblRecord.RefNoScat
)
ON tblSighting.KeySigthing = tblRecord.RefNoSighting
)
ON tblTerritoryName.KeyTerritoryName = tblRecord.RefNoTerritoryName
)
ON tblTrack.KeyTrack = tblRecord.RefNoTrack
)
ON tblUrinBlood.KeyUrinBlood = tblRecord.RefNoUrinBlood
)
ON tblUVNumber.KeyUVNo = tblRecord.RefNoUVNo
)
ON tblValidate.KeyValidate = tblRecord.RefNoValidate
)
ON tblIndividual.KeyIndividual = tblValidate.RefNoIndi
)
ON tblDen.KeyDen = tblRecord.RefNoDen
)
INNER JOIN
tblPersons AS tblPersons_9
ON tblDen.RefNoWriterDen = tblPersons_9.KeyPersons
WHERE
(
((tblRecord.RecRecordNumber) Like [Formularer] ! [frmSearchGeneral].[FindRecord] & "*")
AND
(
(tblUVNumber.UVNo) Like [Formularer] ! [frmSearchGeneral].[FindUV] & "*"
)
AND
(
(tblRecord.RecDate) Between IIf([Forms] ! [frmSearchGeneral].[FindDateStart] Is Null, # 1 / 1 / 1000 # , [Forms] ! [frmSearchGeneral].[FindDateStart]) And IIf([Forms] ! [frmSearchGeneral].[FindDateEnd] Is Null, # 12 / 31 / 9999 # , [Forms] ! [frmSearchGeneral].[FindDateEnd])
)
AND
(
(tblPersons.PerFullName) Like [Formularer] ! [frmSearchGeneral].[FindPerson] & "*"
)
AND
(
(tblPersons.PerOfficielObserver) Like [Formularer] ! [frmSearchGeneral].[FindOfficial] & "*"
)
AND
(
(tblLocation.LocCountry) Like [Formularer] ! [frmSearchGeneral].[FindCountry] & "*"
)
AND
(
(tblLocation.LocProvince) Like [Formularer] ! [frmSearchGeneral].[FindProvince] & "*"
)
AND
(
(tblLocation.LocMuncipality) Like [Formularer] ! [frmSearchGeneral].[FindMuncipality] & "*"
)
AND
(
(tblLocation.LocNearestTown) Like [Formularer] ! [frmSearchGeneral].[FindNearestTown] & "*"
)
AND
(
(tblLocation.LocAreaName) Like [Formularer] ! [frmSearchGeneral].[FindAreaName] & "*"
)
AND
(
(tblFieldTrip.FiTPathNumber) Like [Formularer] ! [frmSearchGeneral].[FindTrackNo] & "*"
)
AND
(
(tblValidate.ValSCALP) Like [Formularer] ! [frmSearchGeneral].[FindSCALP] & "*"
)
AND
(
(tblRecord.RecValidateYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindValidate] = Yes, [Formularer] ! [frmSearchGeneral].[FindValidate], "*")
)
AND
(
(tblRecord.RecScatYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindScat] = Yes, [Formularer] ! [frmSearchGeneral].[FindScat], "*")
)
AND
(
(tblRecord.RecPreyYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindPrey] = Yes, [Formularer] ! [frmSearchGeneral].[FindPrey], "*")
)
AND
(
(tblRecord.RecOtherDNAYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindOtherDNA] = Yes, [Formularer] ! [frmSearchGeneral].[FindOtherDNA], "*")
)
AND
(
(tblRecord.RecSightingYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindSighting] = Yes, [Formularer] ! [frmSearchGeneral].[FindSighting], "*")
)
AND
(
(tblRecord.RecTrackYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindTrack] = Yes, [Formularer] ! [frmSearchGeneral].[FindTrack], "*")
)
AND
(
(tblRecord.RecHowlYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindHowl] = Yes, [Formularer] ! [frmSearchGeneral].[FindHowl], "*")
)
AND
(
(tblRecord.RecUrinBloodYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindUrinBlood] = Yes, [Formularer] ! [frmSearchGeneral].[FindUrinBlood], "*")
)
AND
(
(tblRecord.RecCameraYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindCamera] = Yes, [Formularer] ! [frmSearchGeneral].[FindCamera], "*")
)
AND
(
(tblValidate.ValInsideWolfZone) Like IIf([Formularer] ! [frmSearchGeneral].[FindWolfZone] = Yes, [formularer] ! [frmSearchGeneral].[FindWolfZone], "*")
)
AND
(
(tblValidate.RefNoValSpecies) Like [Formularer] ! [frmSearchGeneral].[FindValidateSpecies] & "*"
)
AND
(
(tblPack.PackName) Like [Formularer] ! [frmSearchGeneral].[FindPack] & "*"
)
AND
(
(tblIndividual.Individual) Like [Formularer] ! [frmSearchGeneral].[FindIndividual] & "*"
)
AND
(
(tblTerritoryName.TerritoryName) Like [formularer] ! [frmSearchGeneral].[FindTerritory] & "*"
)
AND
(
(tblRecord.Deactivated) = False
)
AND
(
(Year([RecDate])) = [Forms] ! [frmSearchGeneral].[FindYearSpecific]
)
)
OR
(
((tblRecord.RecRecordNumber) Like [Formularer] ! [frmSearchGeneral].[FindRecord] & "*")
AND
(
(tblUVNumber.UVNo) Like [Formularer] ! [frmSearchGeneral].[FindUV] & "*"
)
AND
(
(tblRecord.RecDate) Between IIf([Forms] ! [frmSearchGeneral].[FindDateStart] Is Null, # 1 / 1 / 1000 # , [Forms] ! [frmSearchGeneral].[FindDateStart]) And IIf([Forms] ! [frmSearchGeneral].[FindDateEnd] Is Null, # 12 / 31 / 9999 # , [Forms] ! [frmSearchGeneral].[FindDateEnd])
)
AND
(
(tblPersons.PerFullName) Like [Formularer] ! [frmSearchGeneral].[FindPerson] & "*"
)
AND
(
(tblPersons.PerOfficielObserver) Like [Formularer] ! [frmSearchGeneral].[FindOfficial] & "*"
)
AND
(
(tblLocation.LocCountry) Like [Formularer] ! [frmSearchGeneral].[FindCountry] & "*"
)
AND
(
(tblLocation.LocProvince) Like [Formularer] ! [frmSearchGeneral].[FindProvince] & "*"
)
AND
(
(tblLocation.LocMuncipality) Like [Formularer] ! [frmSearchGeneral].[FindMuncipality] & "*"
)
AND
(
(tblLocation.LocNearestTown) Like [Formularer] ! [frmSearchGeneral].[FindNearestTown] & "*"
)
AND
(
(tblLocation.LocAreaName) Like [Formularer] ! [frmSearchGeneral].[FindAreaName] & "*"
)
AND
(
(tblFieldTrip.FiTPathNumber) Like [Formularer] ! [frmSearchGeneral].[FindTrackNo] & "*"
)
AND
(
(tblValidate.ValSCALP) Like [Formularer] ! [frmSearchGeneral].[FindSCALP] & "*"
)
AND
(
(tblRecord.RecValidateYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindValidate] = Yes, [Formularer] ! [frmSearchGeneral].[FindValidate], "*")
)
AND
(
(tblRecord.RecScatYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindScat] = Yes, [Formularer] ! [frmSearchGeneral].[FindScat], "*")
)
AND
(
(tblRecord.RecPreyYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindPrey] = Yes, [Formularer] ! [frmSearchGeneral].[FindPrey], "*")
)
AND
(
(tblRecord.RecOtherDNAYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindOtherDNA] = Yes, [Formularer] ! [frmSearchGeneral].[FindOtherDNA], "*")
)
AND
(
(tblRecord.RecSightingYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindSighting] = Yes, [Formularer] ! [frmSearchGeneral].[FindSighting], "*")
)
AND
(
(tblRecord.RecTrackYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindTrack] = Yes, [Formularer] ! [frmSearchGeneral].[FindTrack], "*")
)
AND
(
(tblRecord.RecHowlYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindHowl] = Yes, [Formularer] ! [frmSearchGeneral].[FindHowl], "*")
)
AND
(
(tblRecord.RecUrinBloodYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindUrinBlood] = Yes, [Formularer] ! [frmSearchGeneral].[FindUrinBlood], "*")
)
AND
(
(tblRecord.RecCameraYes) Like IIf([Formularer] ! [frmSearchGeneral].[FindCamera] = Yes, [Formularer] ! [frmSearchGeneral].[FindCamera], "*")
)
AND
(
(tblValidate.ValInsideWolfZone) Like IIf([Formularer] ! [frmSearchGeneral].[FindWolfZone] = Yes, [formularer] ! [frmSearchGeneral].[FindWolfZone], "*")
)
AND
(
(tblValidate.RefNoValSpecies) Like [Formularer] ! [frmSearchGeneral].[FindValidateSpecies] & "*"
)
AND
(
(tblPack.PackName) Like [Formularer] ! [frmSearchGeneral].[FindPack] & "*"
)
AND
(
(tblIndividual.Individual) Like [Formularer] ! [frmSearchGeneral].[FindIndividual] & "*"
)
AND
(
(tblTerritoryName.TerritoryName) Like [formularer] ! [frmSearchGeneral].[FindTerritory] & "*"
)
AND
(
(tblRecord.Deactivated) = False
)
AND
(
(Year([RecDate])) Between IIf([Forms] ! [frmSearchGeneral].[FindYearStart] Is Null, # 1 / 1 / 1000 # , [Forms] ! [frmSearchGeneral].[FindYearStart]) And IIf([Forms] ! [frmSearchGeneral].[FindYearEnd] Is Null, # 12 / 31 / 9999 # , [Forms] ! [frmSearchGeneral].[FindYearEnd])
)
AND
(
([Forms] ! [frmSearchGeneral].[FindYearSpecific]) Is Null
)
)
;
This is where Access goes from a 2 minute search and then delivers the results as it should to giving me:
"Query too complex"
The only thing I have done is to add two tables (tblDen
and tblPersons_9
) and two columns more RecDenYes
(from tblRecords
) and PerFullName
(from tblPersons_9
)
To make the query complete I need to add another two tables (tblAnimal_2
and tblAnimal_3
) to be able to add the two columns (AniNumberOfAnimals
and AniNumberOfAnimals
) these will give me the number of animals from tblHowl
and tblTrack
.