I have a data table in ms access and I would like to store the first value in column PartNo and the proceed to search column NoSale to see if the same number is in that column. The matching numbers will not be in the same row. After a match is found I would like to then delete both rows in which the number occurs. After that is complete I would like to move to the next number in column PartNo and repeat the process. If any one can help it would greatly be appreciated. Here is what I have so far. Please advise!
Dim cnConn As New ADODB.Connection
Set cnConn = New ADODB.Connection
With cnConn
.Provider = "microsoft.jet.oledb.4.0; " & _
"persist security info=false; "
.ConnectionString = "data source= " & _
App.Path & "\diesel1.mdb"
.Open
End With
Dim rsSel As ADODB.Recordset
Set rsSel = New ADODB.Recordset
With rsSel
.ActiveConnection = cnConn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Source = "select * from FIP WHERE "
.Open "FIP", cnConn, adOpenKeyset, adLockOptimistic, adCmdTable
Dim StrTemp
Dim strPart
rsSel.MoveFirst
Do While Not rsSel.EOF
strPart = !PartNo
Do While Not rsSel.EOF
If !NoSale = strPart Then
rsSel.Delete (adAffectGroup)
End If
rsSel.MoveNext
Loop
rsSel
Loop
End With
End Sub
Dim cnConn As New ADODB.Connection
Set cnConn = New ADODB.Connection
With cnConn
.Provider = "microsoft.jet.oledb.4.0; " & _
"persist security info=false; "
.ConnectionString = "data source= " & _
App.Path & "\diesel1.mdb"
.Open
End With
Dim rsSel As ADODB.Recordset
Set rsSel = New ADODB.Recordset
With rsSel
.ActiveConnection = cnConn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Source = "select * from FIP WHERE "
.Open "FIP", cnConn, adOpenKeyset, adLockOptimistic, adCmdTable
Dim StrTemp
Dim strPart
rsSel.MoveFirst
Do While Not rsSel.EOF
strPart = !PartNo
Do While Not rsSel.EOF
If !NoSale = strPart Then
rsSel.Delete (adAffectGroup)
End If
rsSel.MoveNext
Loop
rsSel
Loop
End With
End Sub