Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 10:19 AM
dkintheuk
Guest
 
Posts: n/a
Default Requery of form based on saved query...

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
Default 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
Default Re: Requery of form based on saved query...

Genius and obvious at the same time...

Many thanks.

Rob.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles