Advertisement
Advertisement
| 10.11.2008 at 07:25PM PDT, ID: 23807255 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: |
Option Explicit
Public Sub ImportCSVFile(cFileName as string, cDatabaseFileName As String,
cTableName As String)
'This subroutine imports data from a comma delimited file (Windows Format)
'into an Access database.
' The three required parameters are:
' 1. the name of the CSV file to be imported (cFileName)
' (e.g. "C:\MyData\Calendar.CSV")
' 2. the name of the database (cDatabaseFileName)
' (e.g. "C:\MyDatabases\MyDataBase.mdb")
' 3. the name of the Table within that database into which the
' delimited file is to be imported (e.g. "Calendar")
Dim MyWs As Workspace 'Pointer to workspace area in which Access
'database will open
Dim accApp As Access.Application 'Pointer to Access database
Dim fs As Object 'File pointer for Import File (cFileName)
'Set up a workspace in which to open the Access Database
Set MyWs = DBEngine.Workspaces(0)
'Set up a pointer to the Access database
Set accApp = CreateObject("Access.application")
'If Access 10 (97) or later then we can turn off
'the security alert that annoyingly pops up
If accApp.Version >= 10 Then
accApp.AutomationSecurity = 1 ' msoAutomationSecurityLow
End If
'Open the Access database
accApp.OpenCurrentDatabase cDatabaseFileName
'Set up a file pointer to the text file
Set fs = CreateObject("Scripting.FileSystemObject")
'If the file exists then import the data
If fs.FileExists(cFileName) Then
accApp.DoCmd.TransferText acImportDelim, "", cTableName, cFile, True, ""
End If
'Release the pointers
Set fs = Nothing
Set accApp = Nothing
Set MyWs = Nothing
End Sub
|
| Answered By: | boag2000 |
| Expert Since: | 02/07/2004 |
| Accepted Solutions: | 2641 |
| Computer Expertise: | Intermediate |
| Education: | Suffolk Community College, Associate's Degree |