Solved

DAO recordset edit problem

Posted on 2007-11-18
14
448 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 20309288
so, you are going to edit those fields for all the records in  table hdcp
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now