Anyone know how to pause the code until an SQL statement is finished on a database.

The problem is.. im running an SQL statement that creates a table, by querying other tables and sorting the data.

strSQL = "SELECT * INTO tmp_SelectRes IN '" & g_Scdl.ScdlFileName & "' FROM tmp_Select " & strWhere & strOrder
g_dbCatalog.Execute strSQL

Set GetInitialRS = g_Scdl.dbSchedule.OpenRecordset("tmp_SelectRes")

the strWhere and strOrder strings are developed previously in the program.

The problem is, it takes the sql statement a while to do the ORDER BY command, so when the program immediately jumps to the next line and opens the table, the data is there, just not sorted correctly. I need to wait until this sort is finished before I open the table.

HELP! please!

Thanks
Joe