I am new to Access and have a form that displays a list of employees that is fetched from a query. It is a continuous list and I have a way to filter by employee type. I wanted to isolate the new record in the continuous form, so I added a button that changes DataEntry = True
, however, when changing DataEntry = False
, I ran into issues with the filtering working, and they appeared to stem around the RecordSource
.
The filtering is done using a combobox
that calls a simple 'Requery' 'AfterUpdate()', and the query itself gets the values as criteria from the combobox
selection.
In the button to change to DataEntry = False
, I have been trying to assign the RecordSource
as well. Initially, it seemed to work great, but then Access crashed and now I am getting error 3701
once the button is pressed.
I have tried various different syntax to try to set the RecordSource
.
Me.RecordSource = "qryName"
Form.RecordSource = "qryName
Forms!frmName.RecordSource = "qryName
and all of the above with "SELECT * FROM [qryName]"
instead of a simple string.
Each gives me a 3701 error.
What am I doing wrong?
This sounds overly complicated. Just set the Filter property of the form - you can use the combobox to do that:
Me.Filter = "EmployeeType = '" & Me!ComboSelectedType.Value "'"
Me.FilterOn = True
or, if the value is numeric:
Me.Filter = "EmployeeType = " & Me!ComboSelectedType.Value ""
Me.FilterOn = True