Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DAO recordset edit problem

Posted on 2007-11-18
14
Medium Priority
?
500 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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…
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…

596 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