INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help stop table updating

Help stop table updating

(OP)
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:

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.

RE: Help stop table updating

What does the code for inserting the record look like? That is possibly the bit that is inserting the blank record.

RE: Help stop table updating

You mention that you have ONE sub-form, but TWO sub-tables.

Are both on the same sub-form?
If so, what is the sub-form container parent / child relationship?

If you expect individual behaviour for each sub-table, I'd expect 2 sub-forms - one for each table.
I'm also intrigued about it behaving differently - simply due to pasting data as opposed to typing it.

(I have a sneaking suspicion that you have some code in a <On_Click>, <On_Change> event of a text box, (which doesn't fire if you paste and then immediately click a 'save' button)).

Def

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close