Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query executes twice!

Status
Not open for further replies.

richardii

Programmer
Jan 8, 2001
104
GB
I'm using the function below to link data from an Oracle database into access. I run it as an expression in a query based on a table that contains all the table names:

Expr:imp_data([TABLE_NAME])

Function imp_data(cField)
DoCmd.TransferDatabase acLink, "ODBC", "ODBC;DSN=geneva_for_cw;UID=geneva_admin;PWD=geneva_admin;SERVER=GENEVA-EAG;", acTable, "geneva_admin." & cField, "geneva_admin." & cField, False
End Function

However it executes twice - in fact it sometimes produces up to 4 instances of the tables! There's a lot of tables - so I use a Like "ACC*" to select all the ACC* tables.

Can't see why.
Any thoughts appreciated - may not be the best way to do this, but you'd think it would work.
 
If I use code it works fine though - strange:

Dim db As DAO.Database
Dim rsTable As DAO.Recordset

Set db = CurrentDb
Set rsTable = db.OpenRecordset("tbl")
rsTable.MoveFirst
Do While Not rsTable.EOF
DoCmd.TransferDatabase acLink, "ODBC", "ODBC;DSN=geneva_for_cw;UID=geneva_admin;PWD=geneva_admin;SERVER=GENEVA-EAG;", acTable, "geneva_admin." & rsTable![TABLE_NAME], "geneva_admin." & rsTable![TABLE_NAME], False
rsTable.MoveNext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top