我已经在站点上扫描了答案,但是即使已经讨论了运行时错误,我的问题似乎也没有出现。
我在表单中有一个子表单。该表单仅包含三个未绑定的文本字段,您可以在其中输入一个或多个搜索查询条件。
子窗体包含查询返回的记录中的所有详细信息。 如果不查询子表单,则会在数据库中获取所有记录。
当您不查询时,子表单中的所有字段都可以完美显示。可以编辑记录(这是整个表单的目的)。
但是,当您运行查询时,其中一个字段停止工作,我收到运行时错误,并且文本框(已绑定)的值显示为“ #name”。 如果我再次关闭并打开表单,则该字段中的值正确。
该字段在更新后从其他两个字段和一个vba获取值。 这是代码:
Private Sub RefNoProbIndiGuess_AfterUpdate()
'Updates field "ProbIndiGuess" with a combination of individual
'from field "RefNoIndi" and probability from field "RefNoProbIndiGuess"
If RefNoIndi.Column(2) = "NA" Then
Form_subfrmValidate.ProbIndiGuess = "NA"
Else
Form_subfrmValidate.ProbIndiGuess = RefNoProbIndiGuess.Column(1) & " " & RefNoIndi.Column(2)
End If
End Sub
对所选记录的查询是使用访问查询构建器构建的,但是SQL却相当艰巨...:
SELECT tblRecord.Deactivated, tblRecord.KeyRecord, tblRecord.RecordNumber, tblRecord.RefNoUVNo, tblUVNumber.UVNo, tblOtherDNA.OtherSampleNo, tblRecord.Date, tblPersons.FullName, tblLocation.NearestTown, tblLocation.AreaName, tblRecord.RefNoTerritoryName, tblTerritoryName.TerritoryName, tblRecord.SampleType, tblRecord.SampleEvidence, tblValidate.KeyValidate, tblRecord.RefNoValidate, tblRecord.ValidateYes, tblValidate.SCALP, tblRecord.SCALPYes, tblValidate.RefNoValSpecies, tblValidateSpecies.Genus, tblValidateSpecies.Species, tblValidateSpecies.Subspecies, tblValidate.ValidatePerson, tblValidate.Event, tblValidate.ValidationDate, tblValidate.RefNoIndi, tblIndividual.Individual, tblIndividual.IndiSex, tblValidate.IndiAgeAtSampleTime, tblValidate.ProbIndiGuess, tblValidate.RefNoPack, tblPack.PackName, tblValidate.RefNoWriterValidation, tblValidate.DateWrittenValidation, tblRecord.DNAAnalysisYes, tblValidate.RefNoSenckAnalysis, tblValidate.SenckID, tblValidate.SenckOrder, tblValidate.SenckLabID, tblValidate.SenckEDatum, tblValidate.SenckPrice, tblValidate.SenckType_mtDNA, tblValidate.SenckHaploType, tblValidate.SenckInfo_mtDNA, tblValidate.SenckType_NucleusDNA, tblValidate.SenckSex, tblValidate.SenckIndividual, tblValidate.SenckInfo_NucleusDNA, tblValidate.SenckFind, tblValidate.SenckPStatus, tblValidate.SenckPTyp, tblRecord.RefNoPhotoDoc, tblPhotoDoc.PhotoFiles, tblProbIndiGuess.KeyProbIndiGuess, tblProbIndiGuess.ProbIndiGuess, tblValidate.RefNoProbIndiGuess
FROM tblIndividual INNER JOIN ((tblValidateSpecies INNER JOIN (tblSenckAnalysisType INNER JOIN (tblProbIndiGuess INNER JOIN (tblPack INNER JOIN tblValidate ON tblPack.KeyPack = tblValidate.RefNoPack) ON tblProbIndiGuess.KeyProbIndiGuess = tblValidate.RefNoProbIndiGuess) ON tblSenckAnalysisType.KeySenckAnalysisType = tblValidate.RefNoSenckAnalysis) ON tblValidateSpecies.KeyValidateSpecies = tblValidate.RefNoValSpecies) INNER JOIN (tblUVNumber INNER JOIN (tblTerritoryName INNER JOIN (tblPhotoDoc INNER JOIN (tblPersons INNER JOIN (tblOtherDNA INNER JOIN (tblLocation INNER JOIN tblRecord ON tblLocation.KeyLocation = tblRecord.RefNoLocation) ON tblOtherDNA.KeyOtherDNA = tblRecord.RefNoOtherDNA) ON tblPersons.KeyPersons = tblRecord.RefNoInformer) ON tblPhotoDoc.KeyPhoto = tblRecord.RefNoPhotoDoc) ON tblTerritoryName.KeyTerritoryName = tblRecord.RefNoTerritoryName) ON tblUVNumber.KeyUVNo = tblRecord.RefNoUVNo) ON tblValidate.KeyValidate = tblRecord.RefNoValidate) ON tblIndividual.KeyIndividual = tblValidate.RefNoIndi
WHERE (((tblRecord.Deactivated)=False) AND ((tblRecord.RecordNumber) Like [Formularer]![frmValidate].[FindRecordNumber] & "*") AND ((tblUVNumber.UVNo) Like [Formularer]![frmValidate].[FindUVNumber] & "*") AND ((tblOtherDNA.OtherSampleNo) Like [Formularer]![frmValidate].[FindOtherSampleNumber] & "*"));
我确信答案很简单,但我似乎无法绕开它。