How to sort a subform from vba (1 Viewer)

KitaYama

Well-known member
Local time
Tomorrow, 07:39
Joined
Jan 6, 2022
Messages
1,541
I can call a function from any main form and sort it based on a specific requirement.

Code:
Public Sub ReSortForm (frmName as string)
  
    Dim frm as Form
    Dim CurrentSort As String
  
    Set frm = Forms(frmName)
    With frm
        CurrentSort = .OrderBy
        ..... Do something here
        ' Resort form with show order
        If SortThis = "Reset" Then
            frm.OrderByOn = False
        Else
            .OrderBy = tbl & SortThis & " " & AscDesc & SecondSort
            .OrderByOn = True
        End If
    End With
  
    ..... other actions here

But if I call the same function from a sub form , the following line fails.
Set frm = Forms(frmName)

Because Access doesn't see a sub form as an opened form.

Is there any way to go around this?

thank you.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:39
Joined
Feb 19, 2013
Messages
16,616
Are you able to use it in vba too?
yes - code as you show.

I found this example - not all the possible arrow codes but gives you a flavour
1667294280710.png



="abc " & ChrW("&H21D2") produces abc ⇒

?val("&H21D2")
8658
so does ="abc " & ChrW(8658)

so easy enough to loop through several thousand possible values to find all the options

Up to now I've been using rich text to combine different fonts in one control (such as arial and webdings)

Richtext has it's benefits - for text boxes you can set colour/weight/etc differently for each font and if you use conditional formatting, it will only impact text that has not been 'rich text formatted'
 

Users who are viewing this thread

Top Bottom