Connecting Tech Pros Worldwide Help | Site Map

Requery of form based on saved query...

  #1  
Old November 13th, 2005, 10:19 AM
dkintheuk
Guest
 
Posts: 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.

  #2  
Old November 13th, 2005, 10:19 AM
Salad
Guest
 
Posts: n/a

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.
  #3  
Old November 13th, 2005, 10:19 AM
dkintheuk
Guest
 
Posts: n/a

re: Requery of form based on saved query...


Genius and obvious at the same time...

Many thanks.

Rob.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
autofill on a form tess@conwaycorp.net answers 8 July 12th, 2007 06:05 PM
Query By Form Using Same Sub Form and Main Form tomlebold@msn.com answers 1 April 21st, 2007 03:55 AM
Updating subform records after closing popup form Macbane answers 4 February 2nd, 2007 04:25 PM
Simple workaround to slow Find or unusable Seek on attached tables! Bob C. answers 3 November 13th, 2005 04:15 AM