View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech[_2_] Jim Rech[_2_] is offline
external usenet poster
 
Posts: 533
Default Variable not seen

oStyle, boMsgYes, boMsgNo, and boMsgCancel are declared globally
elsewhere.


Maybe so but your function declares a local set of variables with the same
names:

Function oMsgBox1(oStyle As String, oNumPrompts As Long, Prompt1 As
String, Prompt2 As String, Prompt3 As String, Prompt4 As String, Title As
String)


You can go two ways at least-

1. Set the global values before calling Function oMsgBox1 and pass nothing
to it.
2. Set global versions of the local variables in the function:

Function oMsgBox1(...)
PuboStyle=oStyle

Btw, if your Function oMsgBox1 returns nothing, as it appears, it shouldn't
be a function. Make it a Sub.

--
Jim
"Geoff" wrote in message
...
|I cannot work out why the variable oStyle is not 'seen' by the message form's
| cmdOkNo_Click procedure. Should be simple but I've gone blank:
|
| From a form I call a custom message box form which can have a combination
of
| Yes, No, Cancel or OK cmdbuttons. However I use only 3 buttons by
switching
| No and Ok on the same button. The messaging and configuring of the message
| box is done in a module:
|
| Public Function oMsgBox1(oStyle As String, oNumPrompts As Long, Prompt1 As
| String, Prompt2 As String, Prompt3 As String, Prompt4 As String, Title As
| String)
|
| ..code
|
| End Function
|
| The oStyle string can be "OK" or "YNC" or "YN"
|
| oStyle, boMsgYes, boMsgNo, and boMsgCancel are declared globally
elsewhere.
|
| In the message form code I have:
|
| Private Sub cmdOkNo_Click()
| If oStyle = "YN" Or oStyle = "YNC" Then ''' oStyle remains ""
| boMsgNo = True
| End If
| other stuff
| End Sub
|
| Private Sub cmdYes_Click()
| boMsgYes = True
| other stuff
| End Sub
|
| Private Sub cmdCancel_Click()
| boMsgCancel = True
| other stuff
| End Sub
|
| T.I.A.
|
| Geoff
|