| re: Requery of form based on saved query...
dkintheuk wrote:[color=blue]
> 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.
>[/color]
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. |