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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to check tables within the Access db?

Status
Not open for further replies.

Mayo123

Technical User
Apr 23, 2005
58
US
The following codes will transfer the text file into my database. But if I run this code again, it will append the records to the existing table again. I want to check the database to see if there's such a table, if so, I will delete it and then transfer the text file into the database. Is it possible to check the database objects??
Thanks for your help!

MyValue = InputBox(Message, Title, Default)
myFile = "C:\" & MyValue & ".txt"
DoCmd.TransferText acImportDelim, "OT_ImportSpecification", MyValue, myFile, False, ""
 
A crude way:
MyValue = InputBox(Message, Title, Default)
On Error Resume Next
If CurrentDB.TableDefs(MyValue).Name > "" Then
CurrentDB.Execute "DROP TABLE [" & MyValue & "]"
End If
On Error GoTo 0
myFile = "C:\" & MyValue & ".txt"
DoCmd.TransferText acImportDelim, "OT_ImportSpecification", MyValue, myFile, False, ""

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, PHV!
You're always so helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top