JMongi
Active member
- Local time
- Today, 01:36
- Joined
- Jan 6, 2021
- Messages
- 802
@The_Doc_Man - I was about to make a long winded post because I didn't understand your caveats, but after rereading post #6, I think I realize why I caused such a distrubance! So, now, a different long-winded post
My original question was meant to be narrow in scope in that I was crafting it with the assumption that all other circumstances were equal (circumstances related to your "whether the object containing the propery is visible to SQL" comment). That question has been answered. A function that returns a string and a property that returns a string are the same (keeping all of the other caveats and circumstances in mind). A string is a string is a string.
Here is the code I posted for reference:
But, in the actual code, two different string functions were used in two different ways (which I failed to notice). One was used in such a way that VBA evaluated the function and returned a string which was then used to concatenate a string for passing to the SQL engine. This is the one used in the WHERE clause. All well and good. That code ALSO uses a function as a function. This is the one in the UPDATE clause. This was passed as function (not an evaluated string) to the SQL engine with the presumption that the SQL engine can somehow communicate with VBA to get that translated into the string that it needs to work correctly. That is where (I think) The_Doc_Man is highlighting the moving parts that allow or don't allow that to happen.
@isladogs - Thanks for the post, I will check it out.
@MajP - Thanks for the SQL/VBA code bookmark.
The wisdom of splitting the SQL string generation via VBA from the SQL execution has become much clearer to me now.
If I'm missing anything in this, let me know please. Thanks!
My original question was meant to be narrow in scope in that I was crafting it with the assumption that all other circumstances were equal (circumstances related to your "whether the object containing the propery is visible to SQL" comment). That question has been answered. A function that returns a string and a property that returns a string are the same (keeping all of the other caveats and circumstances in mind). A string is a string is a string.
Here is the code I posted for reference:
SQL:
CurrentDb.Execute "UPDATE tblUsers SET LoggedIn = True, Computer = GetComputerName()" & _
" WHERE UserName='" & GetDomainUsername() & "' AND tblUsers.Active=True;"
But, in the actual code, two different string functions were used in two different ways (which I failed to notice). One was used in such a way that VBA evaluated the function and returned a string which was then used to concatenate a string for passing to the SQL engine. This is the one used in the WHERE clause. All well and good. That code ALSO uses a function as a function. This is the one in the UPDATE clause. This was passed as function (not an evaluated string) to the SQL engine with the presumption that the SQL engine can somehow communicate with VBA to get that translated into the string that it needs to work correctly. That is where (I think) The_Doc_Man is highlighting the moving parts that allow or don't allow that to happen.
@isladogs - Thanks for the post, I will check it out.
@MajP - Thanks for the SQL/VBA code bookmark.
The wisdom of splitting the SQL string generation via VBA from the SQL execution has become much clearer to me now.
If I'm missing anything in this, let me know please. Thanks!