herb said:
Crystal,
Is it possible to pass parameters to a query from VB code. I have
many tables which need copies made and I'd like to use the same
query as above changing the main table name and the new table name
by using parameters to the query!
Thanks in advance.
Herb
The basic syntax, is
SELECT *
INTO NewTable
FROM OldTable
So, if you just fetch a list over the tables you wish to work with,
you should be able to do this through dynamic SQL, if interested.
Here are some ideas (type = 6, linked to Access, type = 4 SQL server, I
think)
Dim rs As adodb.Recordset
Set rs = CurrentProject.Connection.Execute( _
"SELECT name FROM msysobjects " & _
"WHERE type = 6 and left(name,3) <> 'mys'", , adCmdText)
Do While Not rs.EOF
CurrentProject.Connection.Execute _
"SELECT * INTO [" & rs.Fields(0).value & "new] " & _
"FROM [" & rs.Fields(0).value & "]"
rs.MoveNext
Loop