How to change form's properties from code. (1 Viewer)

ListO

Señor Member
Local time
Today, 13:16
Joined
Feb 2, 2000
Messages
162
I'm trying to create a menu item which changes a property on the currently-active form. I would like the code to work on whichever form might be currently active.

I can easily put a button on a form which changes the property, but I'm lost when it gets to trying to address the form's property from outside of it's own module.
 

ListO

Señor Member
Local time
Today, 13:16
Joined
Feb 2, 2000
Messages
162
OK, that got me a little closer, but I don't seem to have the right structure here.

Here's what I have thus far, and it's riddled with errors.

Code:
Function ChangeSort(SortType)
Dim Fname As String
Fname = Screen.ActiveForm.Name
        Select Case SortType
        Case 1
            OrderByOn = True
            Forms!Fname.SortLabel.Caption = "Sort by Created Date"
            Forms!Fname.OrderBy = "[Created]": Forms!Fname.SortLabel.ForeColor = 255
        Case 2
            SortLabel.Caption = "Sort by Modified Date"
            OrderBy = "[Modified]": SortLabel.ForeColor = 255
        Case 3
            SortLabel.Caption = "Sort Normally": SortLabel.ForeColor = 0
            OrderBy = "[Reelnumber],[startnumber],[cuenumber]"
    End Select
End Function

I'm missing some big step.
 

boblarson

Smeghead
Local time
Today, 05:16
Joined
Jan 12, 2001
Messages
32,059
I'm missing some big step.

Yes, you are. You don't refer to a variable in the way you've done. It would be this:

Code:
Function ChangeSort(SortType)
Dim Fname As String
Fname = Screen.ActiveForm.Name
        Select Case SortType
        Case 1
            OrderByOn = True
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"])[/COLOR].SortLabel.Caption = "Sort by Created Date"
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="Red"])[/COLOR].OrderBy = "[Created]" 
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"])[/COLOR].SortLabel.ForeColor = 255
        Case 2
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]SortLabel.Caption = "Sort by Modified Date"
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]OrderBy = "[Modified]"
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]SortLabel.ForeColor = 255
        Case 3
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]SortLabel.Caption = "Sort Normally"
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]SortLabel.ForeColor = 0
            Forms[COLOR="red"]([/COLOR]Fname[COLOR="red"]).[/COLOR]OrderBy = "[Reelnumber],[startnumber],[cuenumber]"
    End Select
End Function
 

ListO

Señor Member
Local time
Today, 13:16
Joined
Feb 2, 2000
Messages
162
That is, of course, the solution. Thanks for putting up with us.

-Curt
 

Users who are viewing this thread

Top Bottom