Results 1 to 2 of 2

Thread: Is there anybody which can HELP me?!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 1999
    Posts
    3

    Post

    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

  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    165

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width