|
-
Oct 12th, 2011, 10:16 PM
#1
Thread Starter
Hyperactive Member
How to display and edit SQL query
I have an Excel 2007 workbook that uses several data connections (SQL queries) to pull data from an Access database. I would like to display the SQL statement for a particular named connection (Msgbox is okay). Then I would like to edit the same connection using VBA. Please help with example VBA code. Thanks.
-
Oct 13th, 2011, 03:58 AM
#2
Re: How to display and edit SQL query
add a userform with a textbox, you can then display and edit your sql query, a command button to continue the code or execute the edited query
could be a textbox in a worksheet, if you do not want a user form
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 13th, 2011, 07:39 PM
#3
Thread Starter
Hyperactive Member
Re: How to display and edit SQL query
Thanks but I'd rather not use a user form. I don't want to change the operation of the report. I'd like to display certain parts of the query in the header of the report being created. Isn't there some way, within the VBA project of the workbook, to capture the text of the SQL command of a named data connection within that workbook?
-
Oct 14th, 2011, 02:14 AM
#4
Re: How to display and edit SQL query
within the VBA project of the workbook, to capture the text of the SQL command of a named data connection within that workbook?
yes, but you asked to display and edit
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 15th, 2011, 05:18 PM
#5
Thread Starter
Hyperactive Member
Re: How to display and edit SQL query
OK, so how do I use a text box to display the SQL statement of a certain 'Data Connection' query? Can you show a VBA code example? I really appreciate your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|