Hello All,
I have an MS Access table into which i import data from excel. I have an Access form that does this for me. My issue is that the data gets imported into the table but it gets stored at random areas in the table. It does not append to the beginning or end of the table but rather just inserts itself into some area(s) of the table. For example, if i import 7 rows of data from excel, it imports as 7 rows into 7 different areas of the table or sometimes as 7 sequential rows into the middle of the table somewhere but not to the beginning or the end of the table. So basically, the user would have to browse through all the records in the table sequentially to find the specific record(s) that was imported last. I have checked for filters and OrderyBy clauses and have cleared them all and it still does the same thing when i import the data from excel. Is there a a code i can add use to my import code so it imports the data to the end of the table rather than the middle of the table somewhere? Any help would be greatly appreciated!
This is the import code that i use:
Private Sub Import_Click()
On Error GoTo Err_Import_Click
If IsNull(tbfile) Or tbfile = "" Then
MsgBox "Please browse and select a valid file to import.", vbCritical, "Invalid File"
Else
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, _
"Table1", tbfile, True
Me.Form.Recordset.MoveLast
DoCmd.GoToRecord , , acLast
Me.Requery
End If
Exit_Import_Click:
Exit Sub
Err_Import_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Import_Click
End Sub
where "tbfile" is the variable that stores the name/path of the excel file to import.
I have an MS Access table into which i import data from excel. I have an Access form that does this for me. My issue is that the data gets imported into the table but it gets stored at random areas in the table. It does not append to the beginning or end of the table but rather just inserts itself into some area(s) of the table. For example, if i import 7 rows of data from excel, it imports as 7 rows into 7 different areas of the table or sometimes as 7 sequential rows into the middle of the table somewhere but not to the beginning or the end of the table. So basically, the user would have to browse through all the records in the table sequentially to find the specific record(s) that was imported last. I have checked for filters and OrderyBy clauses and have cleared them all and it still does the same thing when i import the data from excel. Is there a a code i can add use to my import code so it imports the data to the end of the table rather than the middle of the table somewhere? Any help would be greatly appreciated!
This is the import code that i use:
Private Sub Import_Click()
On Error GoTo Err_Import_Click
If IsNull(tbfile) Or tbfile = "" Then
MsgBox "Please browse and select a valid file to import.", vbCritical, "Invalid File"
Else
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, _
"Table1", tbfile, True
Me.Form.Recordset.MoveLast
DoCmd.GoToRecord , , acLast
Me.Requery
End If
Exit_Import_Click:
Exit Sub
Err_Import_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Import_Click
End Sub
where "tbfile" is the variable that stores the name/path of the excel file to import.