Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: VBA Debugging (from Beginning Access 2000 VBA title)


Message #1 by "Garett Raines" <gtraines@y...> on Tue, 18 Sep 2001 17:38:25
The following program is from pg 90 of the Wrox Beginning Access 2000 VBA 

title:



"

Function MakeIceCream (Optional CocoaToBeAdded As Variant, _

            Optional VanillaToBeAdded As Variant) As String



   If IsMissing(CocoaToBeAdded) Then

      CocoaToBeAdded = True

   Else

      CocoaToBeAdded = False

   Emd If



   If IsMissing(VanillaToBeAdded) Then

      VanillaToBeAdded = True

   Else

      VanillaToBeAdded = False

   End If



End Function

"



Then, several ways are given to call this proceedure. For 

instance "MakeIceCream" or "MakeIceCream(True)", typed into the immediate 

window of the Access2000 VBA editor, work just fine. However, trying to 

set the argument for the second if...else, for instance "MakeIceCream

(True,False)" or "MakeIceCream(,True)" does not work. Assuming that the 

book is not blatantly incorrect, which the publisher claims is not the 

case, there must be some fundamental misunderstanding on my part about for 

this should be entered or called. Does anyone out there have a clue what I 

might be doing wrong? 



The error message given is

"

Compile Error:

Expected: 

"



Thank you very much in advance for any advice you are able to give.



Garett Raines

garett@3...
Message #2 by "John Ruff" <papparuff@c...> on Tue, 18 Sep 2001 10:31:06 -0700
Since this is a function returning a value, do not use parenthesis, use

this



MakeIceCream True 

or

MakeIceCream True,False

or

MakeIceCream ,True





-----Original Message-----

From: Garett Raines [mailto:gtraines@y...] 

Sent: Tuesday, September 18, 2001 5:38 PM

To: Access

Subject: [access] VBA Debugging (from Beginning Access 2000 VBA title)





The following program is from pg 90 of the Wrox Beginning Access 2000

VBA 

title:



"

Function MakeIceCream (Optional CocoaToBeAdded As Variant, _

            Optional VanillaToBeAdded As Variant) As String



   If IsMissing(CocoaToBeAdded) Then

      CocoaToBeAdded = True

   Else

      CocoaToBeAdded = False

   Emd If



   If IsMissing(VanillaToBeAdded) Then

      VanillaToBeAdded = True

   Else

      VanillaToBeAdded = False

   End If



End Function

"



Then, several ways are given to call this proceedure. For 

instance "MakeIceCream" or "MakeIceCream(True)", typed into the

immediate 

window of the Access2000 VBA editor, work just fine. However, trying to 

set the argument for the second if...else, for instance "MakeIceCream

(True,False)" or "MakeIceCream(,True)" does not work. Assuming that the 

book is not blatantly incorrect, which the publisher claims is not the 

case, there must be some fundamental misunderstanding on my part about

for 

this should be entered or called. Does anyone out there have a clue what

I 

might be doing wrong? 



The error message given is

"

Compile Error:

Expected: 

"



Thank you very much in advance for any advice you are able to give.



Garett Raines

garett@3...



---

You are currently subscribed to access as: papparuff@c... To

unsubscribe send a blank email to $subst('Email.Unsub')





Message #3 by "Paul Engel" <pengel@s...> on Tue, 18 Sep 2001 13:48:54 -0400
I'm away from my office and can't test (and I'm old, so I can't remember

everything) but here are a few things to try. First, are you including a

return variable that is declared as a string for the results? For example:

strIceCreamMade = MakeIceCream(true,false)



Have you tried it w/out the parenthasis? I can't remember right now if the

function requires them and the sub doesn't or visa versa.



Why don't you create two variables and declare them as boolean...blnCocoa

and blnVinilla. Set them to your desired values and then pass them to the

function:

blnCocoa = True

blnVinilla = False

strIceCreamMade = MakeIceCream(blnCocoa, blnVinilla)



It almost looks like it is trying to read your sent values as strings

instead of boolean values.)



Hope this helps.

----- Original Message -----

From: "Garett Raines" <gtraines@y...>

To: "Access" <access@p...>

Sent: Tuesday, September 18, 2001 5:38 PM

Subject: [access] VBA Debugging (from Beginning Access 2000 VBA title)





The following program is from pg 90 of the Wrox Beginning Access 2000 VBA

title:



"

Function MakeIceCream (Optional CocoaToBeAdded As Variant, _

            Optional VanillaToBeAdded As Variant) As String



   If IsMissing(CocoaToBeAdded) Then

      CocoaToBeAdded = True

   Else

      CocoaToBeAdded = False

   Emd If



   If IsMissing(VanillaToBeAdded) Then

      VanillaToBeAdded = True

   Else

      VanillaToBeAdded = False

   End If



End Function

"



Then, several ways are given to call this proceedure. For

instance "MakeIceCream" or "MakeIceCream(True)", typed into the immediate

window of the Access2000 VBA editor, work just fine. However, trying to

set the argument for the second if...else, for instance "MakeIceCream

(True,False)" or "MakeIceCream(,True)" does not work. Assuming that the

book is not blatantly incorrect, which the publisher claims is not the

case, there must be some fundamental misunderstanding on my part about for

this should be entered or called. Does anyone out there have a clue what I

might be doing wrong?



The error message given is

"

Compile Error:

Expected: 

"



Thank you very much in advance for any advice you are able to give.



Garett Raines

garett@3...














Message #4 by Garett Raines <gtraines@y...> on Wed, 19 Sep 2001 13:56:52 -0700 (PDT)
Thank you, thank you, thank you for the help!!!





--- Paul Engel <pengel@s...> wrote:

> I'm away from my office and can't test (and I'm old,

> so I can't remember

> everything) but here are a few things to try. First,

> are you including a

> return variable that is declared as a string for the

> results? For example:

> strIceCreamMade = MakeIceCream(true,false)

> 

> Have you tried it w/out the parenthasis? I can't

> remember right now if the

> function requires them and the sub doesn't or visa

> versa.

> 

> Why don't you create two variables and declare them

> as boolean...blnCocoa

> and blnVinilla. Set them to your desired values and

> then pass them to the

> function:

> blnCocoa = True

> blnVinilla = False

> strIceCreamMade = MakeIceCream(blnCocoa, blnVinilla)

> 

> It almost looks like it is trying to read your sent

> values as strings

> instead of boolean values.)

> 

> Hope this helps.

> ----- Original Message -----

> From: "Garett Raines" <gtraines@y...>

> To: "Access" <access@p...>

> Sent: Tuesday, September 18, 2001 5:38 PM

> Subject: [access] VBA Debugging (from Beginning

> Access 2000 VBA title)

> 

> 

> The following program is from pg 90 of the Wrox

> Beginning Access 2000 VBA

> title:

> 

> "

> Function MakeIceCream (Optional CocoaToBeAdded As

> Variant, _

>             Optional VanillaToBeAdded As Variant) As

> String

> 

>    If IsMissing(CocoaToBeAdded) Then

>       CocoaToBeAdded = True

>    Else

>       CocoaToBeAdded = False

>    Emd If

> 

>    If IsMissing(VanillaToBeAdded) Then

>       VanillaToBeAdded = True

>    Else

>       VanillaToBeAdded = False

>    End If

> 

> End Function

> "

> 

> Then, several ways are given to call this

> proceedure. For

> instance "MakeIceCream" or "MakeIceCream(True)",

> typed into the immediate

> window of the Access2000 VBA editor, work just fine.

> However, trying to

> set the argument for the second if...else, for

> instance "MakeIceCream

> (True,False)" or "MakeIceCream(,True)" does not

> work. Assuming that the

> book is not blatantly incorrect, which the publisher

> claims is not the

> case, there must be some fundamental

> misunderstanding on my part about for

> this should be entered or called. Does anyone out

> there have a clue what I

> might be doing wrong?

> 

> The error message given is

> "

> Compile Error:

> Expected: 

> "

> 

> Thank you very much in advance for any advice you

> are able to give.

> 

> Garett Raines

> garett@3...

> 

> 

Message #5 by "Carol Mandra" <carol_mandra@r...> on Fri, 21 Sep 2001 13:57:36
>Hi there,

  To call a function or procedure using surrounding parenthesis,

   you must use the call statement to avoid your error. For example:

   With parenthesis: Call MakeIceCream(True,False)

                     Call MakeIceCream(,True)



  Without parenthesis: MakeIceCream True,False

                       MakeIceCream ,False

  Carol ;-)



The following program is from pg 90 of the Wrox Beginning Access 2000 VBA 

> Function MakeIceCream (Optional CocoaToBeAdded As Variant, _

>             Optional VanillaToBeAdded As Variant) As String

> 

>    If IsMissing(CocoaToBeAdded) Then

>       CocoaToBeAdded = True

>    Else

>       CocoaToBeAdded = False

>    End If

> 

>    If IsMissing(VanillaToBeAdded) Then

>       VanillaToBeAdded = True

>    Else

>       VanillaToBeAdded = False

>    End If

> End Function

> 

> "MakeIceCream" or "MakeIceCream(True)", typed into the immediate 

> window of the Access2000 VBA editor, work just fine. However, trying to 

> set the argument for the second if...else, for instance "MakeIceCream

> (True,False)" or "MakeIceCream(,True)" does not work.  The error message 

given is   > Compile Error: Expected: 

> 

> Thank you very much in advance for any advice you are able to give.

> Garett Raines

> garett@3...

  Return to Index