If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Next without for? arrrrgh VBA!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 104
Next without for? arrrrgh VBA!

I am really getting fed up with VBA. I'm a c/c++ guy myself.
Ok, quick one

I get a "Next Without For" runtime error for this code. Can anyone help me find out what's wrong?

Code:
  For x = 1 To 10
    
        val = Me("cmbobxGroup" & CStr(x)).Value
        If (val <> "") Then
            DropDowns(x) = CInt(val)
        Else
            DropDowns(x) = -1 '-1 indicates a null or empty value
        
    Next
Note that I also did try Next x and that did the same thing.
Reply With Quote
  #2 (permalink)  
Old
Grand Poobah
 
Join Date: Sep 2003
Location: MI
Posts: 3,713
You have an error else where in the program ... Check your other for ... next loops.

Be aware: VB/VBA can propagate errors VERY FAR away from the point of origin ... It is frustrating.
Reply With Quote
  #3 (permalink)  
Old
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,739
you have a missing endif

izy
__________________
currently using SS 2008R2
Reply With Quote
  #4 (permalink)  
Old
Grand Poobah
 
Join Date: Sep 2003
Location: MI
Posts: 3,713
It's not often that I miss the missing endif ... I must be going blind ...
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 104
Oh that darned End If.
LOOOL.

thanx for the help guys. I am used to C/C++/java not forcing u to have an "end if"
LOL
Reply With Quote
  #6 (permalink)  
Old
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,739
Code:
{
                                       {yeah
}}}}}} i guess this
                                                           sort of stuff}
{must be}
                 }
               }
     much}
 easier}
    to}
                                                         read}
izy
__________________
currently using SS 2008R2
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
Join Date: Oct 2003
Location: Ger
Posts: 1,969
Re: Next without for? arrrrgh VBA!

Quote:
Originally posted by shassouneh
I am really getting fed up with VBA. I'm a c/c++ guy myself.
Ok, quick one

I get a "Next Without For" runtime error for this code. Can anyone help me find out what's wrong?

Code:
  For x = 1 To 10
    
        val = Me("cmbobxGroup" & CStr(x)).Value
        If (val <> "") Then
            DropDowns(x) = CInt(val)
        Else
            DropDowns(x) = -1 '-1 indicates a null or empty value
        
    Next
Note that I also did try Next x and that did the same thing.
The Syntax of If in VB is like that
If Condition then
&nbsp;&nbsp; do smoething
else
&nbsp;&nbsp; another thing
endif

And you forgot the Endif
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 104
LOL izy. I just got used to c/c++ syntax that VB syntax just bugs me.

Code:
ReturnType FunctionName(parameterList)
{

      This->Seems[To.Be] = Much->EasierToRead;
       (than)VB.code
}//end of function
LOL
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On