tags:

views:

52

answers:

1

Hi,

I Have recordset rc1 that reads values from txt file. The fields are rtn, amt, name. Now I get the data from table t_rec and assigned it to another recordset rc2. and compare with the recordset rc1.

If rd1.Fields![AccountNbr] = rc2.Fields![RTProvided] Then
      Set rc2.Fields![ClaimStatus] = "c"
          rc2.Fields![DateClosed] = CqDate
          rc2.Fields![Audit_LastUpdated] = CqDate
          rc2.Fields![Audit_UserAdded] = "System"

If i compile that program i am getting errr like Invalid use of property in vb6. Can you help me.

Sub DneFroceClose()

CqDate = Format(Date, "dd/MM/yyyy")

Set rcdreclamation = New ADODB.Recordset
With rcdreclamation
    .ActiveConnection = objConn
    .Source = "SELECT * FROM T_DATA_reclamation"
    .CursorType = adOpenDynamic
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .Open
End With

frmDNELoad.lblStatus.Caption = "Adding record " & lngRecCount & " of " & rcdreclamation.RecordCount & " to database."
frmDNELoad.Refresh

rcdDNE.Open
rcdreclamation.Open
rcdDNE.MoveFirst
rcdreclamation.MoveFirst

Do Until rcdDNE.EOF

  Do Until rcdreclamation.EOF

     If rcdDNE.Fields![AccountNbr] = rcdreclamation.Fields![RTProvided] Then
      Set rcdreclamation.Fields![ClaimStatus] = "c"
          rcdreclamation.Fields![DateClosed] = CqDate
          rcdreclamation.Fields![Audit_LastUpdated] = CqDate
          rcdreclamation.Fields![Audit_UserAdded] = "System"
          Exit Do
     Else
     rcdreclamation.MoveNext
     End If

  Loop
   rcdDNE.MoveNext
   rcdreclamation.MoveFirst

Loop

End Sub
+2  A: 

Looking at the code above, I see problem with this line of code

Set rc2.Fields![ClaimStatus] = "c"

You don't need Set here.
It should have been rc2.Fields![ClaimStatus] = "c" (if this is the problematic line).

EDIT: I saw your reply to my question. And the same rule applies to the line in question.

Instead of
Set rcdreclamation.Fields![ClaimStatus] = "c"
it should be
rcdreclamation.Fields![ClaimStatus] = "c"

EDIT2: Set is needed when you are assigning to an object variable, an object instance or Nothing.

EDIT3: Also, you could write rcdreclamation![ClaimStatus] instead of rcdreclamation.Fields![ClaimStatus] for each such line.
(disclaimer: I hope I am right on my VB6 syntax. Its been quite some time).

shahkalpesh
yes, you are right. Thanks For your help. I have one more question. after updating that info how to save the data that i have modified into sql table ?
pbrp
Please put in simple words, what you are trying to do? Are you trying to read a text file (CSV, tab separated) and wanting to INSERT those records into a SQL database?
shahkalpesh
No I already did that. I read the text file and insert those value into a table tb1. Now I want compare tb1 values with another table tb2. if tb1.rt1 = tb2.rt2 then cstatus =c, date = now. After that how to update this values in the table2. I hope you got my view. If not let me know I will explain clearly.
pbrp
Instead of doing comparison by looping through recordset, you could do an UPDATE instead. e.g. UPDATE table2, table1 set table2.cstatus = 'C', table2.date = currentTime WHERE table2.rt2 = table1.rt1 (roughly, this is what I could think when looked at your comment above).
shahkalpesh