PC Review


Reply
Thread Tools Rate Thread

Compile Error: Expected end of statement

 
 
=?Utf-8?B?S2lyayBQLg==?=
Guest
Posts: n/a
 
      2nd Mar 2005
I've got a Select Case function like this:

Public Function AcctClass2(GLAccount As String)

Select Case GLAccount
Case 100010 To 100037, 102242, 102250, 102280, 10231X
AcctClass2 = "Cash"

GLAccount is a text field that I'm feeding to this function as an argument.
It doesn't like the X at the end of the Case line, and I get a compile error.
How do I handle this statement to include the X?
 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      2nd Mar 2005
On Wed, 2 Mar 2005 10:37:05 -0800, "Kirk P."
<(E-Mail Removed)> wrote:

>I've got a Select Case function like this:
>
>Public Function AcctClass2(GLAccount As String)
>
> Select Case GLAccount
> Case 100010 To 100037, 102242, 102250, 102280, 10231X
> AcctClass2 = "Cash"
>
>GLAccount is a text field that I'm feeding to this function as an argument.
>It doesn't like the X at the end of the Case line, and I get a compile error.
> How do I handle this statement to include the X?


Try enclosing the GLAccount values in "double quotes" so they'll be
treated as strings rather than numbers.

John W. Vinson[MVP]
 
Reply With Quote
 
=?Utf-8?B?S2lyayBQLg==?=
Guest
Posts: n/a
 
      2nd Mar 2005
I knew it was something simple. Thanks!

"John Vinson" wrote:

> On Wed, 2 Mar 2005 10:37:05 -0800, "Kirk P."
> <(E-Mail Removed)> wrote:
>
> >I've got a Select Case function like this:
> >
> >Public Function AcctClass2(GLAccount As String)
> >
> > Select Case GLAccount
> > Case 100010 To 100037, 102242, 102250, 102280, 10231X
> > AcctClass2 = "Cash"
> >
> >GLAccount is a text field that I'm feeding to this function as an argument.
> >It doesn't like the X at the end of the Case line, and I get a compile error.
> > How do I handle this statement to include the X?

>
> Try enclosing the GLAccount values in "double quotes" so they'll be
> treated as strings rather than numbers.
>
> John W. Vinson[MVP]
>

 
Reply With Quote
 
David C. Holley
Guest
Posts: n/a
 
      3rd Mar 2005
Your missing the END SELECT

Select Case myValue
Case "hello"
Case "foobar"
Case else
End Select

Its a VERY good idea to get into the habit of immediately closing a
statement when required when you open it, BEFORE you write any code. So
if you're writing a Select Case, you would type

Select Case
End Select

right off the bat.

Am I the only or are there others that thing that it would be a great
addition to VBA for VBA to automatically close a statement when needed,
in the same way that typing Sub or Function automatically adds the End
Sub or End Function statements

David H

Kirk P. wrote:
> I've got a Select Case function like this:
>
> Public Function AcctClass2(GLAccount As String)
>
> Select Case GLAccount
> Case 100010 To 100037, 102242, 102250, 102280, 10231X
> AcctClass2 = "Cash"
>
> GLAccount is a text field that I'm feeding to this function as an argument.
> It doesn't like the X at the end of the Case line, and I get a compile error.
> How do I handle this statement to include the X?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INSERT INTO gets compile error: Expected end of statement. ToppHatt Microsoft Access VBA Modules 3 21st Feb 2010 03:59 PM
Compile Error: Expected:( Squeaky Microsoft Excel Programming 2 22nd Jan 2010 05:33 PM
Micrsoft Visual Basic Compile error: Expected: end of statement =?Utf-8?B?SUo=?= Microsoft Excel Misc 5 23rd Oct 2006 12:08 AM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 19th May 2004 02:41 AM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 17th May 2004 08:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:09 PM.