Public Function ImportOrders()
Dim lngColumn As Long
Dim xlx As Object
Dim xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set xlx = CreateObject("Excel.Application")
'xlx.Visible = True
Set xlw = xlx.Workbooks.Open(Me.txtImportPath & Me.cboDirectoryName & "\" & Me.txtFileName)
'Set xls = xlw.Worksheets(1)
Set xls = xlw.Worksheets(Me.cboWorksheetName.Value)
Set xlc = xls.Range("A2")
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblOrderImport", dbOpenDynaset, dbSeeChanges)
UpdateUser ("Importing " & xls.usedrange.rows.Count - 1 & " Orders from Orders spreadsheet...")
Do While xlc.Value
rst.AddNew
'Always minus 1 field/column extra then the column count of the Excel spreadsheet
For lngColumn = 0 To rst.Fields.Count - 6
rst.Fields(lngColumn).Value = xlc.Offset(0, lngColumn).Value
Next lngColumn
rst.Update
Set xlc = xlc.Offset(1, 0)
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
xlx.Close
Set xlx = Nothing
xlx.Quit
End Function