Solved

DAO recordset edit problem

Posted on 2007-11-18
14
491 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

728 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