Save/secure combobox filter result.

PierreR

Registered User.
Local time
Today, 00:27
Joined
Jul 21, 2004
Messages
101
I have a combobox limiting student slots to a certain number on a form 1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;...


Code:
Private Sub cboName_AfterUpdate()
  
    On Error GoTo Err_cboName_AfterUpdate
    Dim strSQL As String

    strSQL = "SELECT * FROM qryAssignmentJunction WHERE StudentID <= " & Me.cboName & ";"
    
    Me.RecordSource = strSQL
    Me.Requery
    
Exit_cboName_AfterUpdate:
   Exit Sub
    
Err_cboName_AfterUpdate:
    MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
    Resume Exit_cboName_AfterUpdate

End Sub
It works great but...

The problem is that after closing the form and opening it again, all the records show and not those of the last filter. Maybe the answer is to somehow permanently change the referenced query?

Does anyone know how to fix this so the last filter result is secured?
 
Last edited:
Pierre,

Use the Search Facility here and look for QueryDef. This will allow you to
save the combo's RowSource.

Wayne
 
Wayne,

I don't think the answer is there. I've bound the combox to a field on the form (just for that purpose), but it doesn't work.

Does it not take very simple coding to change the query to reflect the new number?

Pierre.
 

Users who are viewing this thread

Back
Top Bottom