alanTuring
alanTuring

Reputation: 73

Access 2013 Recordsource quirk

I'm doing some development work on an Access 2013 database. Originally, it was designed so that the record source was set at design time and a filter was added to restrict the records on Open. For a couple of reasons, I changed this to where the record source is being cast in code as the form opens - Me.Form.RecordSource = SQLstr

But when I do this, where the form should be displaying 5 records, it only displays 1 and that is a new record.

When I look at the query in the design screen, the query returns the correct record set.

Curiously, when the form is open, at the bottom of the form, the filter button is yellow. When I click on that, the whole set shows. When I click it again, the set does not change, but continues to show the same (correct) set.

I don't see any code in the filter (there was, but I've removed it). If I clear the Filter in code, then the filter button is disabled and I can only see the one record.

Does anyone see something I'm missing here?

Thanks - Alan

Upvotes: 0

Views: 95

Answers (1)

alanTuring
alanTuring

Reputation: 73

OK, it looks like I was going too far in referencing the form:

Me.form.RecordSource = SQLstr

puts the code in the correct place (or seems to) but doesn't execute right.

If I use: Me.RecordSource = SQLstr

Then it works correctly - displays no filter icon on the form and show the right result set

Not sure how referencing the form causes a problem and why (if it causes a problem) it doesn't fail. But that's what I'm getting

Upvotes: 1

Related Questions