I have a subform which I use for data entry and editing. There are two tables which are potentially updated and the query behind the form is:
When I am entering data via this form there will always be a Soil Analysis Result and that will update Table tblSoilAnalysisResults. Sometimes there will be a Lime Requirement and that will update tblLimeRequirements using this code behind one of the buttons:
The form works as I want it, except for one particular scenario. If I have entered a Soil Analysis Result but there is no Lime Requirement and I copy the complete line of data from the form and paste it as a new record then I get a new blank record in the table tblLimeRequirements which I don’t want. Does anyone have any suggestions as to how I can stop this happening please.
Thank you in advance for any suggestions.
Code:
SELECT tblSoilAnalysisResults.AnalysisNumber, tblSoilAnalysisResults.FieldCode, tblSoilAnalysisResults.DateOfAnalysis, tblSoilAnalysisResults.LabRef, tblSoilAnalysisResults.pH, tblSoilAnalysisResults.[Pmg/l], tblSoilAnalysisResults.PIndex, tblSoilAnalysisResults.[Kmg/l], tblSoilAnalysisResults.KIndex, tblSoilAnalysisResults.[Mgmg/l], tblSoilAnalysisResults.MgIndex, tblSoilAnalysisResults.Analysiscomments, tblSoilAnalysisResults.[%Sand], tblSoilAnalysisResults.[%Silt], tblSoilAnalysisResults.[%Clay], tblSoilAnalysisResults.LabTestTexturalClassification, tblSoilAnalysisResults.LabTestSoilType, tblSoilAnalysisResults.UseResinNutBal, tblSoilAnalysisResults.TraceElementAnalysis, tblSoilAnalysisResults.SoylMapped, tblLimeRequirements.AnalysisNumber, tblLimeRequirements.FieldCode AS FieldCodeLR, tblLimeRequirements.DateTested, tblLimeRequirements.pH, tblLimeRequirements.[LimeRequiredT/Ha], tblLimeRequirements.SourceOfRecommendation, tblLimeRequirements.RequirementNotes, tblLimeRequirements.LabRef
FROM (tblTEMPFieldList INNER JOIN tblSoilAnalysisResults ON tblTEMPFieldList.FieldCode = tblSoilAnalysisResults.FieldCode) LEFT JOIN tblLimeRequirements ON tblSoilAnalysisResults.AnalysisNumber = tblLimeRequirements.AnalysisNumber
ORDER BY tblSoilAnalysisResults.DateOfAnalysis DESC;
When I am entering data via this form there will always be a Soil Analysis Result and that will update Table tblSoilAnalysisResults. Sometimes there will be a Lime Requirement and that will update tblLimeRequirements using this code behind one of the buttons:
Code:
Private Sub LimeRequiredT_Ha_AfterUpdate()
' sub 2 and Me.DateTested are in the lime required section
Me.DateTested = Me.DateOfAnalysis
Me.pH2 = Me.pH
Me.FieldCode2 = Parent!FieldCode
Me.AnalysisNumber2 = Me.AnalysisNumber
Me.LabRef2 = Me.LabRef
SourceOfRecommendation.SetFocus
End Sub
The form works as I want it, except for one particular scenario. If I have entered a Soil Analysis Result but there is no Lime Requirement and I copy the complete line of data from the form and paste it as a new record then I get a new blank record in the table tblLimeRequirements which I don’t want. Does anyone have any suggestions as to how I can stop this happening please.
Thank you in advance for any suggestions.