473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

naming an Access error log file following import using VB function

I want to import a large number of Excel spreadsheets that are 'supposed' to have the same number of columns representaing the same type of data into tables in an Access database. The UNC path and filename are stored in an Access table ("chemoabstract"). I run the following function, which searches the table for a matching file ID and hopefully imports the data into a file named whatever MYFILEID is. What I would like to do is flag up instances of import errors and rename the error log files so that I can identify them appropriately, i.e MYFILEID_ImportErrors. All ideas gratefully received.

Function ImportChemoSSheets(MYFILEID As String)
'Import Spreadsheets
'MYFILEID = filename (e.g. 100_1)
'[Filename] = path e.g. C:\MyDocuments\
'[Extension] = file type = ".xls"
Dim MyDB As Database 'Current database
Dim MyTbl As Recordset
Dim strUNC As String
Dim strTableName As String
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTbl = MyDB.OpenRecordset("Chemoabstract")

If MyTbl.BOF And MyTbl.EOF Then
MyTbl.Close
Set MyTbl = Nothing
Exit Function
End If

MyTbl.MoveFirst

Do While Not MyTbl.EOF
If MYFILEID <> MyTbl![FILEID] Then
MyTbl.MoveNext
Else
strTableName = MyTbl![FILEID]
strUNC = MyTbl![FileName] & MyTbl![FILEID] & MyTbl![FileExtension]
DoCmd.TransferSpreadsheet acImport, 8, strTableName, strUNC, True, ""
MyTbl.MoveNext
End If
Loop
MyTbl.Close
Set MyTbl = Nothing
Set MyDB = Nothing
End Function
Oct 27 '06 #1
0 1191

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
1
by: stuart.medlin | last post by:
I have an Access 2003 application that I recently converted from Access 97. I have a routine in which I use to export the data that the users have keyed into a text file. This text file resides...
0
by: Ducknut | last post by:
Hi all, Thanks in advance, I have form in an access db (Access 2000) that users can use to (hopefully) import a raw .txt file into access. The user clicks a button and a FileDialog opens to select...
4
by: RgeeK | last post by:
I have a main module doStuff.py and another module utility.py. At the start of doStuff.py I call import utility.py Then I also proceed to initiallize some global variables sName = "" ...
6
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.