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

Set onclick command for a button with selection

Status
Not open for further replies.

davejam

Technical User
Jan 6, 2004
313
GB
Hi all,

I have a dropdown combo box that i use to change fields displayed on an input / search form.

With each selection a different tab is selected allowing the user to search on different products / customers / suppliers etc....

obviously for each of these different searches / inputs i want to run a different process on submitting the form.

So my main question is, can i set a command button to access a different sub or functionfrom my code.

tried setting the .onclick = func1, unfortunately this runs func1 with the selection not the button.

tried setting the .onclick = "func1", unfortunately when i click the button it tells me there is no macro named func1!!!

is there some syntax i need to insert before "func1" to get it to change the onclick function to my function.
should i be adding in somewhere [event procedure]!!!!!

I know i can use several if statements within the command button but would really like to keep the code tidy by setting this on selection of my pull down.

is this possible, or am i just insane!!!

Any pointers greatfully received

cheers

daveJam

*two wrongs don't make a right..... but three lefts do!!!!*
 
if you want the button to run a function that is in a different location and is private, try putting the function in a separate module and using Call.

The below is another way where the module1 contains the function IsNothing.

Then you can use IsNothing() in another sub or function eg.
If IsNothing(TxtName) then ..

Nvm if this isnt what you wanted just trying to lend a hand.
Code:
Public Function IsNothing(varToTest As Variant) As Integer
'  Tests for a "logical" nothing based on data type
'  Empty and Null = Nothing
'  Number < 0 is Nothing
'  Zero length string is Nothing
'  Date/Time is never Nothing

    IsNothing = True

    Select Case VarType(varToTest)
        Case vbEmpty
            Exit Function
        Case vbNull
            Exit Function
        Case vbBoolean
            If varToTest Then IsNothing = False
        Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbDecimal
            'Changed from <> 0 to >= 0 for this dbase need 0 for ppi amounts
            If varToTest >= 0 Then IsNothing = False
        Case vbDate
            IsNothing = False
        Case vbString
            If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing = False
    End Select

End Function



---------------------------------------

Neil
 
Take a look at the Eval function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top