开发者

Invalid use of property in vb6

开发者 https://www.devze.com 2022-12-13 22:00 出处:网络
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. andcompare with the recordset rc1.

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/开发者_如何学GoMM/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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消