-
Create Table (SQL) in VBA using an Array and String Variable
Hello All -
1. I'm trying to create a table in a MySQL DB by using a SQL statement via VBA in excel.
2. I have a named range in a hidden worksheet where I'm storing the field names after the user selects column headings from a visible data worksheet.
3. Because I do not know how many fields will be selected I created an Array that will include all non-blanks in the named range located in the hidden worksheet. The array is now a list of the field names that must be included in my SQL CREATE TABLE statement.
4. My problem is I can't figure out how to incorporate a dynamic SQL statement that will include only and all the elements in the array.
5. One suggestion I received was to create a string variable and write to that while I process / loop through each element in my array. Then, I can pass the string variable in an SQL statement as I connect to the MySQL DB via VBA.
Can anyone explain how to loop through an array (of field names) and store those names in a string variable that will be used in a SQL CREATE TABLE statement via VBA?
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