Requery Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a form with a button that when clicked will recreate the query (using
querydefs) that is the forms recordsource. I then attempt to requery the
form but the records do not change. If I manualy look at the query the
records have indeed changed. For instance, the query has 500 records. Once
I click the button and rerun the query it now has 10. However the form is
still showing 500 records. The only way I seem to get the form to show the
proper records is to close it and reopen. Any suggestions would be
appreciated?

On the buttons click event I put the following but it has no effect other
then creating the querydef sucessfully.

If CreateItemsQuery Then
Forms!frmDisplayItems.Requery
'me.requery
End If

THANK YOU.
 
Hi Franky,

If you have a form that has a query for its recordsource, me.requery will
force a refresh of the records - end of story. Why do you need to try to
recreate something using querydefs? If anything, you would try to recreate a
SQL string and save that to the recordsource property before requerying...

More info please.

Damian.
 
Not sure why you are using querydef, but I would just use a sql string like:

strsql= Select * from mytable where Date = #02/27/07# ;"
then me.RecordSource=strsql
me.Requery


Damon
 
You were correct. I've modified my code to change the recordsource rather
than a querydef... Wasn't thinking. The requery works fine now. My form
generates the recordsource sql from other forms that are hidden until needed.
I got in a querydef mode and wouldn't let go.

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top