Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub or Function not defined 2

Status
Not open for further replies.

Matsul

IS-IT--Management
May 6, 2002
140
BE
I created a form . If I run a procedure

Public Sub CCForm_Click()
CCForm_Initialize
End Sub

the form functions successfully.

If I call it from a macro I get Sub or Function not defined. The macro is in a module (Module1) of the same project.

Any ideas ?
 
If you are in the form, it is already Initialized. However, you can always Initialize again...the procedure can be run. So _Click works, because the form is active.

If you are NOT in the form, you can not _Click the form. Yes, there is a procedure that can be called, but the form is not, in fact, clicked.

To display a form from a module use .Show.

I am curious, why did you use _Click?

Gerry
 
Yes that did the trick. I suppose I used _Click cos I don't know what I am doing. Fist project. Thanks
 
Hi there,

My form needs to return a selection. CmdExit_Click's debug.print shows the value I want.

However, the calling sub suspense which is in module1 does not have the value.

Any idea how I can so about this ?

thanks

Private Sub CmdExit_Click()
Unload Me
TxtCC.Value = "Null"
Debug.Print TxtCC.Value
End Sub


Sub suspense()

CCForm.Show
Debug.Print "return" & TxtCC.Value

End Sub
 
Matsul,

Try this:
Code:
Private Sub CmdExit_Click()
    [b]Me.Hide[/b]
    TxtCC.Value = "Null"
    Debug.Print TxtCC.Value
End Sub


Sub suspense()

    CCForm.Show
    Debug.Print "return" & TxtCC.Value
    [b]Unload CCForm[/b]
End Sub


Regards,
Mike
 
No luck. TxtCC.Value is not getting any value
 
Assuming TxtCC is a TextBox on Userform CCForm then you need to qualify the Textbox name with the Userform name outside its module (i.e. in a standard code module); like this:
Code:
Sub suspense()

    CCForm.Show
    Debug.Print "return" & [b]CCForm.[/b]TxtCC.Value
    Unload CCForm
End Sub


Regards,
Mike
 
Also things don't work so well when you unload the form before other instructions.
Code:
Private Sub CmdExit_Click()
    [b]Unload Me[/b]
    TxtCC.Value = "Null"
    Debug.Print TxtCC.Value
End Sub

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top