Requerying from a radio button

Courtman

Paranoid Android
Local time
Today, 18:34
Joined
Dec 8, 2001
Messages
34
I have a form with a sub-form embedded in it which displays the results of a query. On the form are 3 radio buttons - Date, Name, Number - which specify how the query is sorted.

How can I re-query the sub-form whenever the radio button is changed?
 
You'll need to use your option-group's after-update event
to modify your sub-form's query-SQL, then requery. Here's
an example where an option-group is used to modify a
combo-box to search either by Name or SSN. The idea
would be the same if dealing with a sub-form:
Code:
Private Sub grpSearchFor_AfterUpdate()
Dim strSQL As String

    strSQL = "SELECT SSN, LastName, FirstName FROM tblStaff "
    
    Select Case grpSearchFor
    Case 1
       strSQL = strSQL & "ORDER BY LastName, FirstName; "
       Me![cboFindSomeone].ColumnWidths = "0 in;0.75 in; 0.75 in"
    Case 2
       strSQL = strSQL & "ORDER BY SSN; "
       Me![cboFindSomeone].ColumnWidths = "0.75 in;0.75 in; 0 in"
    End Select
    With Me.cboFindSomeone
       .RowSource = strSQL
       .Requery
       .SetFocus
       .Dropdown
    End With
    
    Me!grpSearchFor = Null

End Sub
HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom