Strange Error

Apologies to all on the delay in getting back to this

The there are 2 buttons on the form, one adds records to one table based on the following code:

Code:
Private Sub LogSam_Click()

Select Case Me.CustomerID
    Case 9
        Select Case Left(Me.SamPre, 1)
        Case "D"
            Call LogCRLExpDiamond
        Case Else
            Call LogCRLExp
        End Select
    Case 74
        Call LogAurora
    Case 14
        Call LogGiralia
    Case 21
        Call LogBellzone
    Case 78
        Call LogKarara
    Case 65
        Select Case Right(Me.SubNum, 4)
        Case "FEED"
            Call LogCRLDTRFeed
        Case "CONC"
            Call LogCRLDTRCONC
        End Select
Case Else
        Call LogRoutine

End Select
 
End Sub

Most of the time it calls the below sub routine "LogRoutine", but it doesn't matter which is called:

Code:
Private Sub LogRoutine()

Const MyTable As String = "tblSampleSubmission"
Const MyField As String = "SampleName"
Dim DB As DAO.Database
Dim rs As DAO.Recordset
Dim intCounter As Double
Dim LastDub As Double
Dim minID, maxID, stdID As Long 'Used for randomly selected ID from table of standards
Dim stdName As String
Set DB = CurrentDb
Set rs = DB.OpenRecordset(MyTable)

'Find maximum and minimum ID number in tblStandards
maxID = DMax("StandardID", "tblStandards")
minID = DMin("StandardID", "tblStandards")





For intCounter = Me.TxtStartValue To Me.txtEndValue Step Me.cboIncrement
        rs.AddNew
        rs.Fields(MyField) = Me.SamPre & intCounter & Me.SamSuf
        rs.Fields("SubmissionNumber") = Me.SubNum
        rs.Fields("CustomerID") = Me.CustomerID
        rs.Fields("SamplePrep") = True
        rs.Fields("Fusion") = True
        rs.Fields("XRF") = True
        rs.Fields("LOI") = True
        rs.Fields("3StageLOI") = Me.chk3StageLOI
        rs.Fields("Magnasat") = Me.chkMagnasat
        rs.Fields("DavisTube") = Me.chkDavisTube
        rs.Fields("RecWt") = Me.chkRecWt
        rs.Fields("Sizing") = Me.Sizing
        rs.Fields("Moisture") = Me.Moisture
        rs.Fields("EnteredBy") = Me.cboEnteredBy
        rs.Fields("Priority") = Me.cboPriority
        rs.Update
       addString = ""
       samplecount = samplecount + 1
       If samplecount = 25 Then
        'Add duplicate record
        addString = " DUP"
        rs.AddNew
        rs.Fields(MyField) = Me.SamPre & intCounter & Me.SamSuf & " DUP"
        rs.Fields("SubmissionNumber") = Me.SubNum
        rs.Fields("CustomerID") = Me.CustomerID
        rs.Fields("SamplePrep") = True
        rs.Fields("Fusion") = True
        rs.Fields("XRF") = True
        rs.Fields("LOI") = True
        rs.Fields("3StageLOI") = Me.chk3StageLOI
        rs.Fields("Magnasat") = Me.chkMagnasat
        rs.Fields("DavisTube") = Me.chkDavisTube
        rs.Fields("RecWt") = Me.chkRecWt
        rs.Fields("Sizing") = False
        rs.Fields("Moisture") = False
        rs.Fields("EnteredBy") = Me.cboEnteredBy
        rs.Fields("Priority") = Me.cboPriority
        rs.Update
        'Add Standard
        stdID = stdCnt
        stdName = DFirst("standard", "tblStandards", "[standardid]= " & stdID)
        rs.AddNew
        rs.Fields(MyField) = "STD1:" & stdName
        rs.Fields("SubmissionNumber") = Me.SubNum
        rs.Fields("CustomerID") = Me.CustomerID
        rs.Fields("SamplePrep") = Me.SamplePrep
        rs.Fields("Fusion") = Me.Fusion
        rs.Fields("XRF") = Me.XRF
        rs.Fields("LOI") = True
        rs.Fields("Sizing") = False
        rs.Fields("Moisture") = False
        rs.Fields("EnteredBy") = Me.cboEnteredBy
        rs.Update
        stdCnt = stdCnt + 1
        samplecount = 0
                
        
        
      End If
    Next intCounter
    rs.Close
   DB.Close
Set rs = Nothing
Set DB = Nothing

Exit_EnterBlast_Click:
    Exit Sub

Err_EnterBlast_Click:
    MsgBox Err.Description
    Resume Exit_EnterBlast_Click

 
      
End Sub

The second button adds all of the added records in the table tblSampleSubmission to other tables using append queries. Not the best way of doing things, but, it has worked fine until now, apart from being slow.

All of this works fine, but when the form is closed, the first record in the table (which is from years ago and isn't related to what is in the form) tblSampleSubmission gets changed to whatever is in the field "Submission Number" on the form. It isn't really a huge inconvenience, just weird that it is happening now.
 
My opinion or guess is the same as it was. The form actually DOES have a recordsource and maybe you've missed it
 

Users who are viewing this thread

Back
Top Bottom