Solved

DAO recordset edit problem

Posted on 2007-11-18
14
484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

733 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