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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Function in Immediate Window 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I have a function, I want to test it, I placed
Code:
? Function_Name
in the 'immediate window'

Nothing happens.....

I put a dummy button on the form, which calls the same function and everything runs fine.

Why won't the function run via the immediate window?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 

And the function is?
Are there any parameters to pass?
Are there any parameters calculated before or in the middle?
 
Code:
Function HLP_Notice()

Dim sBod As String
Dim sSub As String

msgbox "Got Here!"

On Error GoTo Err_HLP_Notice

HLP_Notice = ""

'set the subject
    sSub = "email subject."

    'set the email body text
    sBod = "Dear HLP,<br><br>"
    sBod = sBod & "The following AR has been put on notice.<br><br>"
    sBod = sBod & "Company : " & Me!CompanyName & ", Name : " & Me!FirstName & " " & Me!LastName & "<br><br>"
    sBod = sBod & "Should you require any further information or assistance please let me know.<br><br>"
    sBod = sBod & "The A Team."
    'send the email
    SendEmail "email", sSub, sBod, , "email; email"

'Error handling
Exit_HLP_Notice:
    Exit Function

Err_HLP_Notice:
    MsgBox "Error in HLP_Notice : " & Err.Description
    HLP_Notice = "Error"
    Resume Exit_HLP_Notice
End Function

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 

Is Me. loaded yet when you run the function in immediate?
Does SendEmail sub need any other variables?
 
yes I have the form open when i try to run it and no sendemail doesn't required anything else other than data supplied.

even so I'd expect to get the msgbox "Got Here!" popup, shouldn't I

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
What happens if you comment out the line with Me's in it?
 
Nothing, I even commented out the sendemail line and still no pop-up msg.

I've decided to put a test button on the form and just edit the event proceedure to call what ever function I want for testing.

doing that works fine!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
nope that didn't work!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Two suggestions:

1 - for it to work in the immediate pane -> standard module, not forms/reports class module
2 - since it doesn't return anything, make it a sub?

Roy-Vidar
 
? Forms![name of form].HLP_Notice

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry, it did return something, which I didn't see, disregard #2 [blush]

Roy-Vidar
 
so the immediate window always runs code in the global module, even though I have the form/module open on the screen , that's just stupid.

To run anything in other form/report class modules I have to explicity state the forms!formname

Ok fair enough, thanks for the help.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top