Access 2.0-Strange behavior when using arrays and UPDATE command 
Author Message
 Access 2.0-Strange behavior when using arrays and UPDATE command

Hi,

I'm developing Access 2.0 applications since 5 years. But the followig
problem is impossible for me to solve. I'm writing values from an array to a
table field (about 52 records, field is always NULL at the beginning). The
debug-window shows only correct values for the array and the field after the
update command. But when I then take a look at the table there are other
values in the field. I converted the database to Access97. Everything works
perfectly. But I must develop the program with Access 2.0.

Can someone help?

Thanks very much in advance.

Stefan

Simplyfied version of the sourcecode:
___________

sub test ()

Dim db as Database
Dim dyn as Recordset
Dim i as long

ReDim Array1(8) As Long

Array1(1)=4
Array1(2)=5
Array1(3)=6
Array1(4)=7
Array1(5)=8
Array1(6)=1
Array1(7)=2
Array1(8)=3

Set db=DBEngine(0)(0)
Set dyn = db.OpenRecordset("Test", DB_OPEN_DYNASET)

dyn.MoveFirst
i = 1

Do Until dyn.EOF
    dyn.Edit
    dyn.Field = Array1(i)
    dyn.Update
    Debug.Print dyn.Field1, Array1(i)
    i = i + 1
    If i > 8 Then i = 1
    dyn.MoveNext
Loop

dyn.close
db.close

End Sub
_______________________________

Debug-window-output:
4             4
5             5
6             6
7             7
8             8
1             1
2             2
3             3
4             4
5             5
6             6
7             7
8             8
1             1
2             2
3             3
...

________________________________

Tablevalues of field1 (e.g.):

2
3
4
5
6
7
8
1
2
...

or

7
8
1
2
3
4
5
6
...



Sun, 29 Oct 2000 03:00:00 GMT  
 Access 2.0-Strange behavior when using arrays and UPDATE command

Hi Stefan,

The only thing that comes to mind is whether the Option Base is set to 0 or
1.  If you don't have Option Base 1 then Array1 would be 0 to 7.

Also,  I thnk the syntax in Access 2.0 should by dyn!Field1, not dyn.field1

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:Hi,
:
:I'm developing Access 2.0 applications since 5 years. But the followig
:problem is impossible for me to solve. I'm writing values from an array to
a
:table field (about 52 records, field is always NULL at the beginning). The
:debug-window shows only correct values for the array and the field after
the
:update command. But when I then take a look at the table there are other
:values in the field. I converted the database to Access97. Everything works
:perfectly. But I must develop the program with Access 2.0.
:
:Can someone help?
:
:Thanks very much in advance.
:
:Stefan
:
:
:
:Simplyfied version of the sourcecode:
:___________
:
:sub test ()
:
:Dim db as Database
:Dim dyn as Recordset
:Dim i as long
:
:ReDim Array1(8) As Long
:
:Array1(1)=4
:Array1(2)=5
:Array1(3)=6
:Array1(4)=7
:Array1(5)=8
:Array1(6)=1
:Array1(7)=2
:Array1(8)=3
:
:Set db=DBEngine(0)(0)
:Set dyn = db.OpenRecordset("Test", DB_OPEN_DYNASET)
:
:dyn.MoveFirst
:i = 1
:
:Do Until dyn.EOF
:    dyn.Edit
:    dyn.Field = Array1(i)
:    dyn.Update
:    Debug.Print dyn.Field1, Array1(i)
:    i = i + 1
:    If i > 8 Then i = 1
:    dyn.MoveNext
:Loop
:
:dyn.close
:db.close
:
:End Sub
:_______________________________
:
:Debug-window-output:
:4             4
:5             5
:6             6
:7             7
:8             8
:1             1
:2             2
:3             3
:4             4
:5             5
:6             6
:7             7
:8             8
:1             1
:2             2
:3             3
:...
:
:________________________________
:
:Tablevalues of field1 (e.g.):
:
:2
:3
:4
:5
:6
:7
:8
:1
:2
:...
:
:or
:
:7
:8
:1
:2
:3
:4
:5
:6
:...
:
:
:
:
:



Sun, 29 Oct 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Access 2.0-Strange behavior when using arrays and UPDATE command

2. Strange command button behavior...please help!

3. Array - strange behavior

4. Strange behavior with arrays

5. Strange behavior using printer object

6. Looking for assistance: Strange Behavior using Help

7. Access Developers Handbook - Strange Form Behavior

8. Strange Behavior of Access 2.0 SQL

9. Strange Access behavior - bug?

10. Strange behavior when accessing MySQL

11. Using SQL commands in VBscript to update ACCESS table

12. Using SQL commands in VBscript to update ACCESS table

 

 
Powered by phpBB® Forum Software