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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning values to ADO not working

Status
Not open for further replies.

Castanz

Programmer
Apr 5, 2002
61
US
When I run this code I would expect each field to be assigned the value 1.

Instead, the first record's VOC-lbs is assigned 1. The second record is assigned 2. The third record is assigned 3 and so on.

I have tried batch update and regular update.

How do I fix this?

Thanks in advance.

Code:
Dim rst As ADODB.Recordset
Dim Calc_Value As Single
Set rst = New ADODB.Recordset

With rst
    Set .ActiveConnection = CurrentProject.Connection
    .Source = "EquipmentUsage"
    .CursorLocation = adUseClient
    .LockType = adLockBatchOptimistic
    .CursorType = adOpenKeyset
    .Open
    .MoveFirst
    Do While Not .EOF
        Calc_Value = 1
        .Fields("VOC_Lbs") = Calc_Value 
        .MoveNext
    Loop
    .UpdateBatch
        
End With
rst.Close
Set rst = Nothing
 
There is somethingelse going on that you are not telling us. It looked fine to me so I ran it and it works fine.
 
Thanks, it appears I was keeping track of a running sum in my report. The code was updating the table, but the report was showing my a running sum. Thanks for checking that out for me.
 
Apparently the "somethingelse going on that you are not telling us" as suggested by MajP was that your question involved a report. Please try to include all the significant information in your posts ;-)

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top