Solved

DAO recordset edit problem

Posted on 2007-11-18
14
477 Views
Last Modified: 2013-11-27
Do Until EOF(intFilenum)
lngInterval = 10
  For intField = 1 To 1435
    Input #intFilenum, varArray(intField)
   Next intField

With rst

Set rst = CurrentDb.OpenRecordset(tableName)

For i = 256 To 265
    'get info here

 '__________________________'dslr start @ 266-256=10_index_______________
     
  a = 10
     P_dslr = varArray(i + a + (0 * lngInterval))
 
 '****************************************************************************
'loops from 0 to 10 records

 Next i
 
End With

   rst.Edit
       rst.Fields("[xflo]").Value = xTime   'shows correct values in debug
       a = rst.EditMode                      'value is 1
       rst.Fields("[itm]").Value = iTm      'shows correct values
   rst.Update

Loop 'same as rs.MoveNext??????

This work isn't mine so if I need moveFirst moveNext etc I'm not sure how to do it with the For loop which I need

rst.Close
End Sub
no error msgs
rst has over 90 records only compleats 1 record
The edit does't look like it can find the record row
I'm overlooking something and can't see it.

 
0
Comment
Question by:afreer2
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20308925
can you explain how do you pick the records that you want to edit.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 20308945
Can you show us all the code for the sub/function?
0
 

Author Comment

by:afreer2
ID: 20309125
yes I think there is another way to do this but not much code here.

Option Compare Database
Option Explicit
Option Base 1

Sub numRacAlo()
Call GetRace
tableName = "hdcp"
Dim intField As Integer
Dim intFilenum As Integer
Dim varArray(1 To 1435) As Variant
Dim rst As DAO.Recordset
Dim lngInterval As Integer
Dim racePick As Variant
Dim i, a, P_dslr, C_Dslr, pfin, xTime, iTm As Integer
Dim hos1, hos2 As String

intFilenum = FreeFile
Open racePicked For Input As #intFilenum

Do Until EOF(intFilenum)
lngInterval = 10
  For intField = 1 To 1435
    Input #intFilenum, varArray(intField)
  Next intField
    Set rst = CurrentDb.OpenRecordset(tableName)
    xTime = 1
    pfin = 0
    iTm = 0
hos1 = varArray(45)
C_Dslr = varArray(224)

With rst

For i = 256 To 265
         'would refer to this recent PP table
         'increase index by a (missing array indexes)
  If IsEmpty(varArray(i)) Then 'no more data if date is null GO TO NEXT LINE
      intField = 0
     
    Exit For
  Else
  '__________________________'dslr start @ 266-256=10________________
     
  a = 10
     P_dslr = varArray(i + a + (0 * lngInterval))
 
 '****************************************************************************

 
   hos2 = varArray(45)
                       '616- 625 Finish Position
             a = 350 '=index of 616 fin
    pfin = varArray(i + a + (1 * lngInterval))
                If hos1 = hos2 Then
                                   If pfin < 4 Then
                                   iTm = iTm + 1
                                   End If
                                   
                                   If C_Dslr < 46 And P_dslr < 46 Then
                                   xTime = xTime + 1
                                      Else
                                     xTime = xTime

                                     Exit For
                                   End If
                                   
                                   
                End If
 End If

 'On Error Resume Next
     
 Next i
 
End With

   rst.Edit
       rst.Fields("[xflo]").Value = xTime
       a = rst.EditMode
       rst.Fields("[itm]").Value = iTm
   rst.Update
 
   
Loop
rst.Close
End Sub
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20309179
afreer2,
can you answer the question  i posted?  
how do you pick the records that you want to edit?
0
 

Author Comment

by:afreer2
ID: 20309273
I guess I implied  the fieild at edit time.
   rst.Fields("[xflo]").Value = xTime
      rst.Fields("[itm]").Value = iTm
iTm is a field in the rst I set
tableName = "hdcp"
Set rst = CurrentDb.OpenRecordset(tableName)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20309288
so, you are going to edit those fields for all the records in  table hdcp
0
 

Author Comment

by:afreer2
ID: 20309296
yes
0
 

Accepted Solution

by:
afreer2 earned 0 total points
ID: 20313193
I made a new table and used same code but changed edit to addnew  and it functioned fine.
Does any one still care why addnew works and edit does not?
0
 

Author Comment

by:afreer2
ID: 20314306
OK
Mod. please close and refund pts
0
 
LVL 44

Expert Comment

by:GRayL
ID: 20316037
Addnew adds a new record into which you can then fill in any of the fields.  Edit opens the current record so you can modify any of the fields.  See the difference?
0
 

Author Comment

by:afreer2
ID: 20322356
yes
In this case addnew will update all records and edit will not
Same code for both, I seem to need another loop to edit all records.
I did this another way but I think I could use more education on loops and multi recordsets for future use.
Looks like many more questions beyond this one.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 20322445
You have to copy the URL of this question and send a request to Community Support to close the question - pasting in the URL
0
 
LVL 1

Expert Comment

by:modus_operandi
ID: 20384967
Closed, 500 points refunded.
modus_operandi
EE Moderator
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question