Use a variable for a Form reference

S

scott56hannah

I am developing an application in Excel and need to allow for multiple screen
sizes. I have been referred to an article by Tom Ogilvy back in 2004 that
describes how to determine the screen resolution and from their differing
User Forms based on that screen resolution can be shown.

I have a number of routines that validate and initilise the data in the form
that will basically be duplicated unless I can find a way to use a parameter
for the Form name....

For example....instead of the code below explicity referring to the
VendorEntry_1280x1024 form I want to be able to use a variable that is passed
into the routine for all screen resolutions.....is that possible ?

The error that is returned when I try and use a variable is..."compile
error: invalid qualifer"


Public Sub RefreshVendorDataEntry_1280x1024()
'Routine only used to refresh the values in the list box

'Remove any selection within the List Box
VendorEntry_1280x1024.VendorDataListBox.ListIndex = -1
VendorEntry_1280x1024.VendorSalesStaffMember.ListIndex = -1



Any help appreciated
 
O

OssieMac

I am not sure if my interpretation of what you are trying to achieve is
correct. However, the following assigns a form to a variable and passes it to
another procedure to initialize text boxes.

Sub Calling_Sub()
Dim VendorEntry_1280x1024
Set VendorEntry_1280x1024 = UserForm1
Call Init_Txt_Boxes(VendorEntry_1280x1024)
End Sub


Sub Init_Txt_Boxes(myParam)
myParam.VendorDataListBox.ListIndex = -1
myParam.VendorSalesStaffMember.ListIndex = -1
myParam.Show
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top