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

Application.run Subform Procedure? 1

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,207
0
0
US
This is making me crazy...

Code:
Application.Run "Forms!" & Me.Name & "![subform Control].Form." & strCreateRecordsCallback 'Crashes 
    'Run Time error 2517 ... cannot find the procedure...

Code:
Forms!MEFormName![subform Control].Form.ProcedureInString 'Runs

What am I doing wrong or what should I do instead?

I'm trying to have strCreateRecordsCallback set by a property in the subform so I can have distinct names...

Maybe I should have a bunch of public procedures with the same name and avoid the application.run part?
 
I get the same error results as you when I use a string as per the intelisense for Application.Run

If I use
Code:
Application.Run  Forms.Item("FormName").FunctionName

The function runs but then I get an error
cannot find the procedure '.'

However, if I use
Code:
Call Forms.Item("FormName").FunctionName

It works just fine.





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

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
Extrapolating further from an SO thread... I think I have found the syntax you are after..

Code:
Dim MethodName As String
Dim FormName as String
MethodName = "Call_Me"
FormName = "My_Test"

CallByName Forms.Item(FormName), MethodName, VbMethod

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

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
So adjusting for my example...

Code:
CallByName Me![subform Control].Form, strCreateRecordsCallback, VbMethod

Verdict: It works!

Thank you! I apparently did not know the right questions to ask help.

I also whined on MSDN feedback for Application.Run that it does not list CallByName as a See Also... Hopefully they fix it and no one had to come here for this solution. This makes me want to put VNC on an old Windows XP machine with Office 97 for the help topics... As much as I complain MS documentation is much better than many others but they also have the resources to be THE example we hold up as the standard.
 
I finally complained on a feedback that the wrong topic came up on the website (as it often did)... sometime after that it told me it was disabled and I had to change it and how. All I remember is it is a buried setting. But well worth the change. I wonder if It was a one-off. Access 2010 for that one. Oh well, I'm dumbfounded they have that on by default... I mean the assumption that there own help topics in the product are so bad... I mean sometimes they are less complete but usually it is the web article that was just missing entirely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top