Sie sind auf Seite 1von 3

FIX: Referencing Data Object Gives Error: Object not an Array Article ID: Q1003 !

Revision Date: 1"#A$G#1%%"

The information in this article applies to: - Professional Edition of Microsoft Visual Basic for Windows, version 3.

&'()*O(&

An "Object not an Array" error results when you reference a field of a dynaset, table, or snapshot object in a form or module that does not contain a Set statement for that dynaset, table, or snapshot. The error occurs when Visual Basic attempts to compile your program.

+A$&E This error is caused by a parsing problem in the Visual Basic programming en ironment. The Visual Basic parser does not recogni!e the object type because there is no Set statement in the same form or module.

,OR-ARO$.D Add a dummy Sub procedure to each form or module, and use a Set statement that refers to the global database " table " dynaset in a meaningful way #for e$ample, Set myds % db.&reate'ynaset#...( not set my's % my's(. )i e the Sub procedure a name li*e +AAAAA,-i$,.arser+ so it becomes the first code parsed in that form or module. /a*e sure the dynaset set in the dummy Sub procedure is the e$act same dynaset that is causing the problem. 0hen adding more than one dummy Sub procedure to a project, gi e each Sub procedure a different name #AAAAA1, AAAAA2, and so on( to a oid name collisions that could complicate your e$isting problem. -or e$ample, use the following dummy procedure if /y's is the dynaset causing the problem3

!u" ######$%i&$Parser !et M'(s ) M'(B.*reate('naset+,...,End !u"

4ou ne er need to e$ecute the code in the Sub procedure or e en call the Sub procedure. Once you add the Sub procedure, the parser sees the Set statement#s( before it tries to parse any other code, so it does not ha e trouble with the global objects. After adding the Sub procedure, you do not ha e to twea* the code e ery time you reload the project5 you can do it once and sa e it.

&*A*$& /icrosoft has confirmed this to be a bug in /icrosoft Visual Basic ersion 6.7 for 0indows. This bug was corrected in /icrosoft Visual Basic ersion 8.7 for 0indows.

(ORE I.FOR(A*IO.

&te/s to Re/ro01ce )roble2

.. !tart Visual Basic or from the %ile menu, choose /ew Pro0ect +#1T, %, /if Visual Basic is alread' runnin2. %orm. is created "' default. 3. %rom the %ile menu, choose /ew Module +#1T, %, M-. Module. is created. 3. #dd a te&t "o& +Te&t.- to %orm.. 4. #dd the followin2 code to the 5eneral section of Module.: 5lo"al M'(s #s ('naset 6. #dd the followin2 code to Module.: !u" main +(im M'(B #s (ata"ase (im !71!tmt #s !trin2 *onst (B$8E#(9/1: ) 4 ; !et constant. !et M'(B ) 9pen(ata"ase+,B<B1<9.M(B,; 9pen data"ase. ; !et te&t for the !71 statement. !71!tmt ) ,!E1E*T = %89M Pu"lishers W>E8E !tate ) ;/:;, ; *reate the new ('naset. !et M'(s ) M'(B.*reate('naset+!71!tmt, (B$8E#(9/1:form..!how End !u" ?. #dd the followin2 code to the %orm$1oad event procedure of %orm.: !u" %orm$1oad +Te&t..Te&t ) M'(s+,state,End !u"

@. %rom the 9ptions menu, choose Pro0ect +#1T, 9, P-. The Pro0ects 9ptions dialo2 is displa'ed. A. %rom the Pro0ect 9ptions dialo2, set the !tart Bp %orm to !u" Main and choose 9C. D. %rom the 8un menu, choose start +#1T, 8, !- or press %6.

The following line of code returns the error "Object not an Array"3

Te&t..te&t ) M'(s+,state,-.

#dditional reference words: "u2list3.

fi&list4.

3.

CB*ate2or': E"interop E"pr2 E""u2list E"fi&list CB!u"cate2or': #Pr2(ata<<!#M Pr2*trls!td

T>E </%98M#T<9/ P89V<(E( </ T>E M<*89!9%T C/9W1E(5E B#!E <! P89V<(E( ,#! <!, W<T>9BT W#88#/T: 9% #/: C</(. M<*89!9%T (<!*1#<M! #11 W#88#/T<E!, E<T>E8 EFP8E!! 98 <MP1<E(, </*1B(</5 T>E W#88#/T<E! 9% ME8*>#/T#B<1<T: #/( %<T/E!! %98 # P#8T<*B1#8 PB8P9!E. </ /9 EVE/T !>#11 M<*89!9%T *98P98#T<9/ 98 <T! !BPP1<E8! BE 1<#B1E %98 #/: (#M#5E! W>#T!9EVE8 </*1B(</5 (<8E*T, </(<8E*T, </*<(E/T#1, *9/!E7BE/T<#1, 19!! 9% BB!</E!! P89%<T! 98 !PE*<#1 (#M#5E!, EVE/ <% M<*89!9%T *98P98#T<9/ 98 <T! !BPP1<E8! >#VE BEE/ #(V<!E( 9% T>E P9!!<B<1<T: 9% !B*> (#M#5E!. !9ME !T#TE! (9 /9T #119W T>E EF*1B!<9/ 98 1<M<T#T<9/ 9% 1<#B<1<T: %98 *9/!E7BE/T<#1 98 </*<(E/T#1 (#M#5E! !9 T>E %98E59</5 1<M<T#T<9/ M#: /9T #PP1:. *op'ri2ht Microsoft *orporation .DD6.

Das könnte Ihnen auch gefallen