Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change SQL property of saved query 2

Status
Not open for further replies.

Aximboy

Technical User
Aug 3, 2003
63
US
I am using this Change SQL property of saved query (DAO) function by Mr. dhookom (faq701-7433) on my form.
However the new strSQL won't load until after I reopen the form the second time around.
Any idea why it isn't loading the first time? Or is there a work around on this?

I am using Access 2013.

Thanks in advance.
 
I'd try saving the QueryDef in code and then forcing a refresh at the form level. If you cannot get a refresh to work, sometimes closing and reopening the form will work (you can do this via code. Of course, that may not be the best option if there is other information added via data entry to the form.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
I believe this is because forms work with a clone of the recordset which isn't changed when you change the underlying source object.

If saving the qd and then doing some sort of me.requery doesn't work, then what's probably happening is that the form is doing a requery based on the old SQL instead of getting the new sql.

There are workarounds, including assigning the SQL directly to the RecordSource property of the form. But report back if the requery doesn't work.
 
Thank you all for responding. I was sick and wasn't able to work and check this forum until this evening.

So upon trying your suggestions, I found that...
Requery doesn't work
"Me.RecordSource = Me.RecordSource" doesn't work

However, assigning the SQL directly to the recordsource did worked. I guess I can get rid of this this "fChangeSQL Function" on my form.




 
Glad you got it resolved. Thanks for sharing the solution that worked for you.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top