J
JB
Hi Folks,
I'm trying to pass the names of controls in a form to a Module so that I can
create a generic function to handle resizing controls regardless of the form
name, list name etc but don't know how to do it......
I have a form called Form1 and a listbox in the form called ListBox1.
I've declared these in the form and then set them to the control names
Public FormName As String
Public ListName As String
Public WidthofList As String
FormName = Me.Name
ListName = Me.lstCommName.Name
WidthofList = Me.lstCommName.Width
I also have an array which I set to testit() Then I pass the array into the
function (which works fine) like..
testit() = MyArray
ResizeList testit()
All ok so far but I get an object required error when it runs in my module!
here's the code..
Public Function ResizeList(testit() As String)
Dim aTempArray() As String 'temp array to hold items for length check
Dim iCharcount As Integer 'number of characters in the committee name
Dim iHighNum As Integer 'highest number of characters so far
Dim i As Integer
aTempArray() = testit()
iHighNum = 0
For i = 0 To UBound(aTempArray, 1)
iCharcount = Len(aTempArray(i))
If iCharcount > iHighNum Then
iHighNum = iCharcount
Else
iHighNum = iHighNum
End If
Next
If iHighNum >= "120" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "640"
ElseIf iHighNum >= "90" And iCharcount < "120" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "440"
ElseIf iHighNum < "90" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "328"
End If
End Function
Any Ideas???
Cheers
I'm trying to pass the names of controls in a form to a Module so that I can
create a generic function to handle resizing controls regardless of the form
name, list name etc but don't know how to do it......
I have a form called Form1 and a listbox in the form called ListBox1.
I've declared these in the form and then set them to the control names
Public FormName As String
Public ListName As String
Public WidthofList As String
FormName = Me.Name
ListName = Me.lstCommName.Name
WidthofList = Me.lstCommName.Width
I also have an array which I set to testit() Then I pass the array into the
function (which works fine) like..
testit() = MyArray
ResizeList testit()
All ok so far but I get an object required error when it runs in my module!
here's the code..
Public Function ResizeList(testit() As String)
Dim aTempArray() As String 'temp array to hold items for length check
Dim iCharcount As Integer 'number of characters in the committee name
Dim iHighNum As Integer 'highest number of characters so far
Dim i As Integer
aTempArray() = testit()
iHighNum = 0
For i = 0 To UBound(aTempArray, 1)
iCharcount = Len(aTempArray(i))
If iCharcount > iHighNum Then
iHighNum = iCharcount
Else
iHighNum = iHighNum
End If
Next
If iHighNum >= "120" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "640"
ElseIf iHighNum >= "90" And iCharcount < "120" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "440"
ElseIf iHighNum < "90" Then
FormName.ListName.Width = WidthofList
FormName.ListName.ColumnWidths = "328"
End If
End Function
Any Ideas???
Cheers