Private Sub MassApprove_Click()
On Error GoTo ErrorHandler
Dim strControl As String
Dim rst As New ADODB.Recordset
Dim rcd As String
strControl = "Forms!txtRecordKey"
strSQL = "SELECT tblImportClaims.FileID&tblImportClaims.FileTabName&tblImportClaims.DefaultCustNbr&tblImportClaims.ClaimTypeDesc AS RecordKey" & _
", tblImportClaims.FileID, tblImportClaims.FilePath, tblImportClaims.FileName, tblImportClaims.FileTabName" & _
", tblImportClaims.FileDate, tblImportClaims.FileSize, tblImportClaims.DefaultCustNbr, tblImportClaims.Analyst" & _
", tblImportClaims.ClaimTypeDesc, tblImportClaimFilesLocal.MassSchemaApprv " & _
"FROM tblImportClaims INNER JOIN tblImportClaimFilesLocal " & _
"ON (tblImportClaims.DefaultCustNbr = tblImportClaimFilesLocal.DefaultCustNbr) " & _
"AND (tblImportClaims.ClaimTypeDesc = tblImportClaimFilesLocal.ClaimTypeDesc) " & _
"AND (tblImportClaims.FileSize = tblImportClaimFilesLocal.FileSize) " & _
"AND (tblImportClaims.FileDate = tblImportClaimFilesLocal.FileDate) " & _
"AND (tblImportClaims.FileName = tblImportClaimFilesLocal.FileName) " & _
"AND (tblImportClaims.FilePath = tblImportClaimFilesLocal.FilePath) " & _
"WHERE tblImportClaimFilesLocal.MassSchemaApprv=-1;"
Debug.Print "strSQL: " & strSQL
With rst
.Open strSQL, CurrentProject.Connection, adOpenStatic, adLockReadOnly
Do While Not rst.EOF
Me.Recordset.FindFirst strControl = rst(0)
Debug.Print "Current Form Record " & Forms!frmImportSchemaCheck.txtFileID & "_" & Forms!frmImportSchemaCheck.FileName & Forms!frmImportSchemaCheck.FileTabName
Debug.Print "Current recordset record: " & rst(0)
DoCmd.RunMacro "mcrTransfertoWorking" 'This macro runs from values in the current form. Form needs to change for each macro.
rst.MoveNext
Loop
rst.Close
End With
Exit Sub
ErrorHandler:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
End Sub
**** Immediate Window ****
Note how the form debug.print values are not updating. This causes the macro to run twice, but on the same form.
strSQL: SELECT tblImportClaims.FileID&tblImportClaims.FileTabName&tblImportClaims.DefaultCustNbr&tblImportClaims.ClaimTypeDesc AS RecordKey, tblImportClaims.FileID, tblImportClaims.FilePath, tblImportClaims.FileName, tblImportClaims.FileTabName, tblImportClaims.FileDate, tblImportClaims.FileSize, tblImportClaims.DefaultCustNbr, tblImportClaims.Analyst, tblImportClaims.ClaimTypeDesc, tblImportClaimFilesLocal.MassSchemaApprv FROM tblImportClaims INNER JOIN tblImportClaimFilesLocal ON (tblImportClaims.DefaultCustNbr = tblImportClaimFilesLocal.DefaultCustNbr) AND (tblImportClaims.ClaimTypeDesc = tblImportClaimFilesLocal.ClaimTypeDesc) AND (tblImportClaims.FileSize = tblImportClaimFilesLocal.FileSize) AND (tblImportClaims.FileDate = tblImportClaimFilesLocal.FileDate) AND (tblImportClaims.FileName = tblImportClaimFilesLocal.FileName) AND (tblImportClaims.FilePath = tblImportClaimFilesLocal.FilePath) WHERE tblImportClaimFilesLocal.MassSchemaApprv=-1;
Current Form Record 14822_092509 Paper Dispute 239630 BSCC ClevelandUPL_1massj.csvNoTab
Current recordset record: 14822NoTab88888888RST
Current Form Record 14822_092509 Paper Dispute 239630 BSCC ClevelandUPL_1massj.csvNoTab
Current recordset record: 14823NoTab88888888RST
|