PDA

View Full Version : Create an Access table from data in an array



agarwaldvk
11-14-2007, 03:47 PM
Hi Everybody

I have a 2 dimensional array with data.

How do I create an Access table with data from this array using VBA.

After creating this table, I need to be able run an SQL on this table to get a summarised recordset.

I know how to do the second bit but not the first..

Can anyone help me with this, please!


Best regards


Deepak Agarwal

XLGibbs
11-18-2007, 12:03 PM
First question might be, how are you creating the array? It may be possible to create the table from within that logic, rather than add additional steps.

You would(could) use


strSQL = "Create Table myTable (col1 double, col2 text(30))"

DoCmd.RunSQL strSQL

'You can then insert into the table the values from your array by building 'the SQL string
'insert 1 at a time
strSQL = "Insert Into myTable(Col1,Col2) Select " & arrayval1 & "," & arrayval2"
doCmd.strSQL