Hello,
So far I have written the following code to load an excel spreadhseet into my database, I use a form with which to control the entry of path names (see below). First my code takes the data into a unprocessed file from its original location and once it has loaded it it sends it to a processed file, at least it seems to work like that!
Private Sub LoadNewData_Click()
Dim subdir As String, strfilename As String, strFullName As String
Dim counter As Integer, Path As String, path2 As String, path3 As
String
strfilename = ""
strFullName = ""
Path = DLookup("[pathdetail]", "tblpaths", "[path]=1"
path2 = DLookup("[pathdetail]", "tblpaths", "[path]=2"
path3 = DLookup("[pathdetail]", "tblpaths", "[path]=3"
strfilename = Dir(Path & "*.XLS"
strFullName = Path & strfilename
counter = 0
Do Until strFullName = Path
FileCopy strFullName, path2 & strfilename
Kill strFullName
strfilename = Dir
strFullName = Path & strfilename
counter = counter + 1
Loop
If counter = 0 Then
MsgBox "No files loaded - original directory was empty", vbOKOnly
ElseIf counter > 0 Then
MsgBox counter & " files have been sucessfully moved to the correct
directory to be processed", vbOKOnly
End If
counter = 0
strfilename = Dir(path2 & "*.XLS"
strFullName = path2 & strfilename
Do Until strFullName = path2
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"tblMainData", strFullName, True
counter = counter + 1
FileCopy strFullName, path3 & "\" & strfilename
Kill (strFullName)
strfilename = Dir
strFullName = path2 & strfilename
Loop
If counter = 0 Then
MsgBox "No files imported as directory was empty", vbOKOnly
ElseIf counter > 0 Then
MsgBox counter & " files have been sucessfully been processed",
vbOKOnly
End If
End Sub
What I would like to do is this (FINALLY getting to the point, sorry)- Is there a way of specifying the row at which you start to load data from on the excel spreadsheet and specifying the last row you wish to export.
i.e. Load data from row 50 to row 100 on spreadsheet x
I would like to do this thorugh a form that you could enter the rows you wished to load.
Thanks for any help, I know you could cut and paste the required data into the table but I would like to automate it, this however may be the completely wrong way of going about it.
Cheers, Ali
So far I have written the following code to load an excel spreadhseet into my database, I use a form with which to control the entry of path names (see below). First my code takes the data into a unprocessed file from its original location and once it has loaded it it sends it to a processed file, at least it seems to work like that!
Private Sub LoadNewData_Click()
Dim subdir As String, strfilename As String, strFullName As String
Dim counter As Integer, Path As String, path2 As String, path3 As
String
strfilename = ""
strFullName = ""
Path = DLookup("[pathdetail]", "tblpaths", "[path]=1"
path2 = DLookup("[pathdetail]", "tblpaths", "[path]=2"
path3 = DLookup("[pathdetail]", "tblpaths", "[path]=3"
strfilename = Dir(Path & "*.XLS"
strFullName = Path & strfilename
counter = 0
Do Until strFullName = Path
FileCopy strFullName, path2 & strfilename
Kill strFullName
strfilename = Dir
strFullName = Path & strfilename
counter = counter + 1
Loop
If counter = 0 Then
MsgBox "No files loaded - original directory was empty", vbOKOnly
ElseIf counter > 0 Then
MsgBox counter & " files have been sucessfully moved to the correct
directory to be processed", vbOKOnly
End If
counter = 0
strfilename = Dir(path2 & "*.XLS"
strFullName = path2 & strfilename
Do Until strFullName = path2
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"tblMainData", strFullName, True
counter = counter + 1
FileCopy strFullName, path3 & "\" & strfilename
Kill (strFullName)
strfilename = Dir
strFullName = path2 & strfilename
Loop
If counter = 0 Then
MsgBox "No files imported as directory was empty", vbOKOnly
ElseIf counter > 0 Then
MsgBox counter & " files have been sucessfully been processed",
vbOKOnly
End If
End Sub
What I would like to do is this (FINALLY getting to the point, sorry)- Is there a way of specifying the row at which you start to load data from on the excel spreadsheet and specifying the last row you wish to export.
i.e. Load data from row 50 to row 100 on spreadsheet x
I would like to do this thorugh a form that you could enter the rows you wished to load.
Thanks for any help, I know you could cut and paste the required data into the table but I would like to automate it, this however may be the completely wrong way of going about it.
Cheers, Ali