Create a variable from a record in a table

G

Geoff Salmon

I want to create a series of tables from a series of Excel spreadsheets. I
have set up a table with the list of the spreadsheets called 'stcknames'.

I then used a command to go to each record in that table. That seems to
work. But I don't know how to access that record and use it as a variable
in the next command set out below. I am missing something basic. I don't
know how to capture the record as then use it as a variable, call it
'nwtable'.

Any help would be appreciated and if the approach itself is misguided, I
would appreciate further direction.

Here is what I have tried to date

Sub NewTabl()

For n = 1 To 2
DoCmd.GoToRecord acDataTable, "stcknames", acGoTo, n

nwtble = ???

DoCmd.TransferSpreadsheet acImport, 8, _
nwtble, "C:\GeoffsFolders\stockdata\stcknames.XLS", True, "a1:f765"
Next n
End Sub
 
D

dandgard

I take it the names you read in are from a text field in the table. Yo
can do the transferspreadsheet where nwtable = text field content.
This should create a new table if one by that name did not exist.

if you are using gotrecord then you must have a recordset available fo
it to act on. so if rs = recordset object then

nwtable = rs!textfieldthathasexcelfilenam
 
D

dandgard

I take it the names you read in are from a text field in the table. Yo
can do the transferspreadsheet where nwtable = text field content.
This should create a new table if one by that name did not exist.

if you are using gotrecord then you must have a recordset available fo
it to act on. so if rs = recordset object then

nwtable = rs!textfieldthathasexcelfilenam
 
D

dandgard

I take it the names you read in are from a text field in the table. Yo
can do the transferspreadsheet where nwtable = text field content.
This should create a new table if one by that name did not exist.

if you are using gotrecord then you must have a recordset available fo
it to act on. so if rs = recordset object then

nwtable = rs!textfieldthathasexcelfilenam
 
D

dandgard

I take it the names you read in are from a text field in the table. Yo
can do the transferspreadsheet where nwtable = text field content.
This should create a new table if one by that name did not exist.

if you are using gotrecord then you must have a recordset available fo
it to act on. so if rs = recordset object then

nwtable = rs!textfieldthathasexcelfilenam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top