SOLVED

Modifying query expression using VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-1990939%22%20slang%3D%22en-US%22%3EModifying%20query%20expression%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990939%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20find%20a%20way%20to%20change%20(overwrite)%20a%20query%20field%20expression%20based%20on%20a%20form%20text%20input%20using%20VBA.%26nbsp%3B%20Is%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEx%3A%20Query%20field%20expression%20%22ProjectID%3A%2012345%22%3C%2FP%3E%3CP%3EEnter%20%2220201%22%20in%20a%20Form%3C%2FP%3E%3CP%3EUpdate%20query%20field%20expression%20to%20%22ProjectID%3A%2020201%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1990939%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1990964%22%20slang%3D%22en-US%22%3ERe%3A%20Modifying%20query%20expression%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990964%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F786198%22%20target%3D%22_blank%22%3E%40JR2020610%3C%2FA%3E%26nbsp%3BYes.%20it%20is%20referred%20to%20as%20%22Dynamic%20SQL%22%20and%20it%20is%20a%20very%20common%20technique%20for%20certain%20tasks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EActually%2C%20I%20know%20of%20%3CA%20href%3D%22https%3A%2F%2Fwww.jstreettech.com%2Fdownloads.aspx%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eone%20excellent%20download%20site%3C%2FA%3E%20where%20you%20can%20get%20the%20VBA%20to%20do%20just%20that.%20Scroll%20that%20page%20to%20find%20%22%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fwww.jstreettech.com%2Ffiles%2FbasJStreetSQLTools.zip%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%3CSPAN%20class%3D%22jstreet%22%3EJ%20Street%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ESQL%20Tools%3C%2FA%3E%22.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I'm trying to find a way to change (overwrite) a query field expression based on a form text input using VBA.  Is this possible?

 

Ex: Query field expression "ProjectID: 12345"

Enter "20201" in a Form

Update query field expression to "ProjectID: 20201"

2 Replies
best response confirmed by JR2020610 (Occasional Contributor)
Solution

@JR2020610 Yes. it is referred to as "Dynamic SQL" and it is a very common technique for certain tasks.

 

Actually, I know of one excellent download site where you can get the VBA to do just that. Scroll that page to find "J Street SQL Tools". 

 

@George Hepworth thank you so much.  This looks like a great resource.