INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Change SQL property of saved query

Change SQL property of saved query

(OP)
I am using this Change SQL property of saved query (DAO) function by Mr. dhookom (FAQ701-7433: How to Change SQL property of saved query (DAO)) 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.

RE: Change SQL property of saved query

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

RE: Change SQL property of saved query

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.

RE: Change SQL property of saved query

You could try run code in the form:

CODE --> vba

Me.RecordSource = Me.RecordSource 

Duane
Hook'D on Access
MS Access MVP

RE: Change SQL property of saved query

(OP)
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.




RE: Change SQL property of saved query

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close