okay...so this is sort of working, but not entirely
Here's the code i'm using for the after update event
Code:
Private Sub cboStatus_AfterUpdate()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("qryStudentList")
Dim sqlStr As String
selectStatus = Me.cboStatus.Value
If selectStatus = "All" Then
sqlStr = "SELECT tblGradStudents.* FROM tblGradStudents ORDER BY tblGradStudents.LastName, tblGradStudents.FirstName;"
Else
sqlStr = "SELECT tblGradStudents.* FROM tblGradStudents WHERE tblGradStudents.Status = '" & selectStatus & "' ORDER BY tblGradStudents.LastName, tblGradStudents.FirstName;"
End If
qdf.SQL = sqlStr
If selectStatus = "All" Then
'Me.Filter = vbNullString
Me.FilterOn = True
Me.FilterOn = False
Else
Me.Filter = "Status = " & selectStatus
Me.FilterOn = True
Me.FilterOn = False
End If
Set qdf = Nothing
Set db = Nothing
setTitle (selectStatus)
End Sub
I have the if statement because "All" is not a status and it would crash...All is supposed to essentially remove any filter and display all records
with the way it is written above, the datasheet in the split form will refresh, or filter, when the combobox is changed...with the exception of the very first time it is changed after the form is opened. The first time it changes i get a "Enter Parameter Value" msgbox with the identifier being whatever option was selected in the combobox. So if I select "Active" in the combobox, then the identifier is "Active"...If cancel is selected instead of OK, then the program crashes...but if OK is selected, then it filters the datasheet and I dont have to worry about the "Enter Parameter Value" msgbox again as long as the form remains open.
When I switch to design view, the Filter property says 'Status = Active', or whatever the first option was that I selected in the combobox. This remains whatever the first option I selected was, even if I change the combobox several times afterward.
Also, the "All" selection does not work if something is not in the filter property.