How to change form's properties from code.

ListO

Señor Member
Local time
Today, 15:47
Joined
Feb 2, 2000
Messages
167
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.
 
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.
 
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
 
That is, of course, the solution. Thanks for putting up with us.

-Curt
 

Users who are viewing this thread

Back
Top Bottom