PDA

Click to See Complete Forum and Search --> : Bastard of a toggle button


Chris 655321
Aug 10th, 2000, 09:12 AM
I'm making a 3 way toggle button, to do sorting. The code I use is:

Dim str As String, tgl As ToggleButton
str = "firstname_table1"
Set tgl = tglFirstName
Select Case tgl.Value
Case True
Me.OrderBy = str & " DESC"
Me.OrderByOn = True
Case False
Me.OrderByOn = False
Case Else
Me.OrderBy = str
Me.OrderByOn = True
End Select

I always get a "Run time error '424' Object Required"

What's the problem??

CGTS
Aug 10th, 2000, 08:02 PM
You Dim'd tgl as ToggleButton ! Is ToggleButton a User Control or User defined Type?

Then you Set tgl = ToggleFirstname !

What is ToggleFirstName?

parksie
Aug 10th, 2000, 08:24 PM
I think ToggleButton is part of the MS Forms 2.0 library, but I'm not sure about the rest.

Chris 655321
Aug 10th, 2000, 08:59 PM
It's a MS Forms 2.0 thing yeah

CGTS
Aug 10th, 2000, 10:06 PM
OK....... if you have the Toggle button in the components bar i.e. you have selected 'Microsoft Forms 2.0 Objects Library' AND you have a Reference to 'Microsoft Access for Windows' OR 'Microsoft Access 8.0 Object Library' you will get this problem. The three libraries differ in the properties available and conflict with each other.

If you only have a toggle button on your form and no references to the above Microsoft Libraries it will work fine.

If you do have these references set for other reasons, you can use Dim tgl as Object and this will create the correct type of object at run time. (Late bound)

I hope this makes sense!

I'm assuming you have the ToggleButton TripleState set to True and your code is in the Sub tglFirstName_Change() routine. I am also presuming that you have Form Properties for OrderBy and OrderByOn. It does'nt make any difference to the answer, but it maybe helps other people reading the thread to understand it better.

Chris 655321
Aug 11th, 2000, 07:52 AM
Ok, I got the toggle button to work...with one exception...it doesn't actually sort my data...it just eventually deletes the first field...