Passing a variable to a backend function from a button?

Access9001

Registered User.
Local time
Today, 06:25
Joined
Feb 18, 2010
Messages
268
I have code that creates a series of buttons and I want to be able to click the first button and have it pass a value to a function, but if I click a different button, it sends a different value, etc.

The function would IDEALLY be the following:

Sub callsheet(sheetNo as integer)
sheets(sheetNo).Activate
End Sub


Where I could pass in sheetNo depending on which button I click. However, it doesn't seem to let me do this very easily. Any workarounds?


Oh shoot I meant to put this in Excel forum
 
Last edited:
I have code that creates a series of buttons

If the above statement is true then you really want to have a rethink on your design. An Access form has a lifetime limit of 754 controls and this includes controls you delete. If you are creating buttons dynamically as your statement suggests, then deleting them, creating them again etc then eventually you will hit this limit and your form will be unusable.
 
Good point -- maybe it is better for me to have the buttons named in a way that corresponds to the row and then dynamically get something listed in another col in that row
 
Without seeing your Database it is difficult to suggest what you should do, I can only say that the current solution is not a good idea!
 

Users who are viewing this thread

Back
Top Bottom