PDA

Click to See Complete Forum and Search --> : Is there anybody which can HELP me?!!!!


Dark Hacker
Jul 11th, 1999, 06:11 PM
I used the following code to transfer the data from Access database into an Excel file, but when I want to make another transfer like this imediatly (with the same procedure) I received an error message which says that the table tabWork doesn't exist.
Can you tell me how can I do a real Refresh of the Table or Query?

Set dbWork = Workspaces(0).OpenDatabase(C:\Access.mdb", False, False, ";pwd=")

dbWork.Execute "SELECT tabDoctors.DocTown AS Town,tabDoctors.DocWPlace AS [Work Place], tabDoctors.DocCode AS Code, tabDoctors.DocFName AS [First Name], tabDoctors.DocLName AS [Last Name], tabDoctors.DocStreet AS Street, tabDoctors.DocBuilding AS Building, tabDoctors.DocWPhone AS [Work Phone], tabDoctors.DocHPhone AS [Home Phone], tabDoctors.DocMPhone AS [Mobil Phone], tabDoctors.DocPosition AS Position, qryTotalCtg.Cat, qryTotalSpc.Spec" _
& " INTO tabWork" _
& " FROM ((tabReps INNER JOIN tabDoctors ON tabReps.RepCode = tabDoctors.RepCode) INNER JOIN qryTotalCtg ON tabDoctors.DocCode = qryTotalCtg.DocCode) INNER JOIN qryTotalSpc ON tabDoctors.DocCode = qryTotalSpc.DocCode" _
& " Where (((tabReps.RepCode) =" & RepCodePr & ") And ((tabReps.RepActuality) = True)) ORDER BY tabDoctors.DocTown, tabDoctors.DocWplace, tabDoctors.DocFName, tabDoctors.DocLName"

DoCmd.OutputTo acOutputTable, "tabWork", "Microsoft Excel (*.xls)", "C:\Temp\Lista Doctori Rep_" & txtRepCodePr & ".xls"

dbWork.Execute "DROP TABLE tabWork"

dbWork.TableDefs.Refresh

J Staniforth
Jul 11th, 1999, 07:29 PM
You deleted(removed) the whole table at the end so this sub cannot run again unless you either recreate the table or just empty it instead of dropping it.

To empty the table;

DELETE * FROM tabWork

This actually just removes the data rather than the structure as well.

Regards,
John