What's Wrong with this Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a simple(theoretically) procedure to open one form and
close another based on the variables passed to it. I've tried this:

Public Sub HandleForms(stDoc1 as string, stDoc2 as string)

Dim stOpen as string
Dim stClose as string

stOpen = stDoc1
stClose = stDoc2

doCmd.OpenForm stOpen

' If there is no form to close skip it
If stClose = "None" then
Exit Sub
End If

doCmd.Close acForm, stClose

End Sub

Then I call it Like this

HandleForms("frmPMMenu", "frmSignIn")

or like this

dim stDocOpen as string
dim stDocClose as string

stDocOpen = "frmPMMenu"
stDocClose = "frmSignIn"

HandleForms(stDocOpen, stDocClose)

In both scenarios I get a compile error in the call telling me that = is
expected.

I'm sure I've missed something very simple but I can't figure it out.

Thanks,

MPJ
 
MJatAflac said:
I am trying to create a simple(theoretically) procedure to open one
form and close another based on the variables passed to it. I've
tried this:

Public Sub HandleForms(stDoc1 as string, stDoc2 as string)

Dim stOpen as string
Dim stClose as string

stOpen = stDoc1
stClose = stDoc2

doCmd.OpenForm stOpen

' If there is no form to close skip it
If stClose = "None" then
Exit Sub
End If

doCmd.Close acForm, stClose

End Sub

Then I call it Like this

HandleForms("frmPMMenu", "frmSignIn")

or like this

dim stDocOpen as string
dim stDocClose as string

stDocOpen = "frmPMMenu"
stDocClose = "frmSignIn"

HandleForms(stDocOpen, stDocClose)

In both scenarios I get a compile error in the call telling me that =
is expected.

I'm sure I've missed something very simple but I can't figure it out.

Thanks,

MPJ

Your syntax for calling your Sub is incorrect. Use either of the two
formats below:

HandleForms stDocOpen, stDocClose

Call HandleForms(stDocOpen, stDocClose)
 
Back
Top