By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

Requery of form based on saved query...

P: n/a
Hi all,

Using Access 2000 on XP Pro PC.

I have a form that is based on a presaved query - all fine with this.

I also have a refresh button that takes the values from various unbound
controls on the form and uses them a the criteria for changing the
query definition that the form is based on - so far so good.

The final line of code behind the refresh is me.requery to refresh the
dataset.

The refresh does not seem to recognise the changed query definition and
reports the previous values.

However, if I manually open the control source query from the form
properties, I can preview the dataset and then on closing the control
source query the form reports the correct values.

What am i doing wrong here?

Many thanks,

Rob.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
dkintheuk wrote:
Hi all,

Using Access 2000 on XP Pro PC.

I have a form that is based on a presaved query - all fine with this.

I also have a refresh button that takes the values from various unbound
controls on the form and uses them a the criteria for changing the
query definition that the form is based on - so far so good.

The final line of code behind the refresh is me.requery to refresh the
dataset.

The refresh does not seem to recognise the changed query definition and
reports the previous values.

However, if I manually open the control source query from the form
properties, I can preview the dataset and then on closing the control
source query the form reports the correct values.

What am i doing wrong here?

Many thanks,

Rob.


Are you changing the query. If so, you don't need to requery. Simply input
Me.Recordsource = <NewRecordSource>
Ex:
Dim s As String
s = "Select * From Emp Where LastName = 'Smith'"
Me.Recordsource = s

Usually my form will have a recordsource like
s = "Select * From Emp"
Me.Recordsource = s
so I have all records available in the table and then I may do some
things like
Dim s As String
s = "HireDate > #1/1/2005# And Dept = 'Accting' And Sex = 'M'"
Me.Filter = s
Me.FilterOn = True
and thus I filter the records based on criteria I have defined on the form.
Nov 13 '05 #2

P: n/a
Genius and obvious at the same time...

Many thanks.

Rob.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.