Array into SQL Statement

JuanPa

New Member
Joined
Jun 9, 2010
Messages
32
Hi, I'm working on a recordset that updates a table (an excel spreadsheet actually) based on the results from a custom form.
The input from the form is an array with the codes of companies that should be included in the query.
Example:
Code:
Dim myArray(1 to 1) As Variant
myArray(1)="001"
What I'd like to do, is to use the array as a "virtual" SQL table in my simple statement below:
Code:
Dim myStatement as String
myStatement="UPDATE [Companies] " & _
                    "SET [Status]='01' " & _
                    "WHERE [CCode] IN " & myArray()
Is it possible to do something like this, obviously my attempt failed. If possible, what am I missing?
Thanks in advance,
JuanPa
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top