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!

Passing parameters to function from Form 1

Status
Not open for further replies.

pharcyder

Programmer
Mar 12, 2002
66
DE
Hello !

I want to pass parameters to a function which is called directly from that button (no code in vba, just the function name entered in the event line).

This works fine if I only pass ONE parameter and it looks like this:
=fct_navigation("next")

But how can I pass more parameters ?
Trying different things with commas always result in errors.
(this won't work: =fct_Navigation("next", "test")

btw. the functions are properly coded, they work absolutely fine when I use the code in a sub for the OnClick-event.

Thanks in advance,
Jens
 
This might be a little long winded, or not suited, but if you are always going to be parsing two arguments it'd work -infact I'm sure you could make it work for one or two parameters:


Code:
Dim strArg1 As String
Dim iArg1 As Integer
Dim strArg2 As String

'Expecting "Argument1|Argument2"

iArg1 = InStr(1, strArgument, "|")
strArg1 = Left(strArgument, iArg1 - 1)
strArg2 = Right(strArgument, Len(strArgument) - (iArg1))


[\code]

Basically, I reckon you could stick that at the start of the receiving function, and it would allow you to parse two parameters.
 
What's the big deal about doing it the "Normal" way ?

ie One line in the On_Click event


G LS
 
Thanks mincefish, I think I´ll do it this way (at last give it a try if it works 'clean')

But I still can't believe there is no possibility to pass parameters 'the normal way'.
Why the heck is Microsoft not using the same syntax ?
Why can't the VBA-developer-team arrange with the form-developer-team how they interpret ..uhm.. 'code' ?

The reason for me doing this, LittleSmudge, is just of cosmetic kind.
I don't want dozens of lines of code just for some buttons doing a navigation... and i don't need to look at the code every time, just enter the function directly in the same window where the data or the name of the button is changed..

Greetings from Germany,
Jens
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top