Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code help- Match syntax fix

Status
Not open for further replies.

EBee

MIS
Aug 10, 2001
229
US
This code doesn't error out, but the data its giving is not 100% correct. I need to know if the match of machine numbers
------------------------------------------------------

rst.FindFirst "Number=" & rstOpen!Number
If Not rstOpen.NoMatch Then

does this code always match together or not all the time. I need a better code to accurately match this machine together. FYI: the rst and rstopen have multiple same machine number, so, the data duplicate in both tables. One table should match all records to the other table.

thanks
---------------------------------------------------


Private Sub Bagout()


Dim db As Database
Dim rst As Recordset
Dim rstOpen As Recordset
Dim rstFirst As Recordset
Dim rstExcept As Recordset
Dim rstSecond As Recordset
Dim intAnswer As Integer
Dim trap_error As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("auxil1", dbOpenDynaset)
Set rstOpen = db.OpenRecordset("Auxil_Logic_Open")
Set rstExcept = db.OpenRecordset("tableExcept")
Set rstSecond = db.OpenRecordset("table789")

On Error GoTo error_Handling

intAnswer = MsgBox(" Did you Run the 2 Bart Report ?", vbYesNo)
If intAnswer = vbNo Then
MsgBox " Process Terminated. . GO TO Bart and Run Auxil2 and AuxilOpen , Thank You"
DoCmd.CancelEvent
Else


error_Handling:

If Err = 3021 Then
trap_error = MsgBox(" The tables maybe empty!!, OR No Match found ", vbOKOnly, "Custom Error Handler")
If trap_error = vbOK Then
Exit Sub
Else
End If
End If

rstOpen.MoveFirst
rst.MoveFirst
Do While Not rst.EOF

rst.MoveNext
rstOpen.MoveNext

rst.FindFirst "Number=" & rstOpen!Number
If Not rstOpen.NoMatch Then

Select Case rst!Trans_Number
Case 7 To 10

If Abs(DateDiff(&quot;n&quot;, rst!Tx_Time, rstOpen!Tx_Time)) < 2 Then

With rstSecond
.AddNew
!Number = rstOpen!Number
!Denom = rstOpen!Denom
!Location = rstOpen!Location
!Emp_Name = rstOpen!Emp_Name
!Tx_Date = rstOpen!Tx_Date
!Tx_Time = rstOpen!Tx_Time
!Trans_Number = rstOpen!Trans_Number
!Trans_Desc = rstOpen!Trans_Desc
.Update
End With

With rstSecond
.AddNew
!Number = rst!Number
!Denom = rst!Denom
!Location = rst!Location
!Emp_Name = rst!Emp_Name
!Tx_Date = rst!Tx_Date
!Tx_Time = rst!Tx_Time
!Trans_Number = rst!Trans_Number
!Trans_Desc = rst!Trans_Desc
.Update
End With
rst.Delete
rstOpen.Delete

End If

End Select
End If

Loop

End If

MsgBox &quot;PROCESS DONE , Thank you &quot;



End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top