Urgent syntax error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

Thanks in Advance.

There is an error in the following code. But I can't see the wood for the
trees. Can you help me.

TableName = "Import_Std-A"

For intCount = 1 To NoFields
strField = "F" & intCount
Set rst = dbs.OpenRecordset("SELECT [" & strField & "] AS MyField
FROM " & TableName)


Thanks

Trev
 
Hi All,

Thanks in Advance.

There is an error in the following code. But I can't see the wood for the
trees. Can you help me.

TableName = "Import_Std-A"

For intCount = 1 To NoFields
strField = "F" & intCount
Set rst = dbs.OpenRecordset("SELECT [" & strField & "] AS MyField
FROM " & TableName)


Thanks

Trev

As posted there are several errors in the code: you have a FOR with no
NEXT, you're defining a recordset variable but you haven't Dim'd it,
you're not DOING anything with it...

and you haven't given us any indication of *what* error you're
getting.

In addition, since you have an illegal - character in the table name,
you'll at the very least need to include square brackets around the
table name as well as the fieldname.

John W. Vinson[MVP]
 
Thanks anyway guys found the error it was the "-" in tableName.

When I replace it with "_" it works fine.



John Vinson said:
Hi All,

Thanks in Advance.

There is an error in the following code. But I can't see the wood for the
trees. Can you help me.

TableName = "Import_Std-A"

For intCount = 1 To NoFields
strField = "F" & intCount
Set rst = dbs.OpenRecordset("SELECT [" & strField & "] AS MyField
FROM " & TableName)


Thanks

Trev

As posted there are several errors in the code: you have a FOR with no
NEXT, you're defining a recordset variable but you haven't Dim'd it,
you're not DOING anything with it...

and you haven't given us any indication of *what* error you're
getting.

In addition, since you have an illegal - character in the table name,
you'll at the very least need to include square brackets around the
table name as well as the fieldname.

John W. Vinson[MVP]
 
Back
Top