Here's my code...
Set rs = New ADODB.Recordset
With rs
.Open "Select * from tblPartNumber", conn, adOpenForwardOnly, adLockPessimistic
For i = 1 To flgPartNum.Rows - 2
If !PartNumber = flgPartNum.TextMatrix(i, 0) Then
!PartNumber = flgPartNum.TextMatrix(i, 0)
!GenDesc = flgPartNum.TextMatrix(i, 2)
!PartDesc = flgPartNum.TextMatrix(i, 3)
End If
If !PartNumber <> flgPartNum.TextMatrix(i, 0) Then
rs.AddNew
!PartNumber = flgPartNum.TextMatrix(i, 0)
!GenDesc = flgPartNum.TextMatrix(i, 2)
!PartDesc = flgPartNum.TextMatrix(i, 3)
End If
Next
rs.Update
rs.MoveNext
End With
I want import the contents of the Flexgrid to my table tblPartNumber ... but with some consideration... if from the flexgrid the partnumber is already existing(in tblPartNumber) then it will edit the record and if not existing will add new record... i think there's a problem with my condition... please advice
Set rs = New ADODB.Recordset
With rs
.Open "Select * from tblPartNumber", conn, adOpenForwardOnly, adLockPessimistic
For i = 1 To flgPartNum.Rows - 2
If !PartNumber = flgPartNum.TextMatrix(i, 0) Then
!PartNumber = flgPartNum.TextMatrix(i, 0)
!GenDesc = flgPartNum.TextMatrix(i, 2)
!PartDesc = flgPartNum.TextMatrix(i, 3)
End If
If !PartNumber <> flgPartNum.TextMatrix(i, 0) Then
rs.AddNew
!PartNumber = flgPartNum.TextMatrix(i, 0)
!GenDesc = flgPartNum.TextMatrix(i, 2)
!PartDesc = flgPartNum.TextMatrix(i, 3)
End If
Next
rs.Update
rs.MoveNext
End With
I want import the contents of the Flexgrid to my table tblPartNumber ... but with some consideration... if from the flexgrid the partnumber is already existing(in tblPartNumber) then it will edit the record and if not existing will add new record... i think there's a problem with my condition... please advice