Hello,
I am working with Access 2010. I have a big Access Database that I got when I took the place of someone else. The database has never really worked correctly as I am told. I would like to see if this is a common problem which it is weird that the DB does this crazy stuff.
I have a form that I have an option to upload an excel sheet. When I press the button the excel sheet uploads, it pops up, then when I open the table it should be going to it only uploads some of the data but not all the data, and when I reopen the excel sheet all the data is gone / columns are renamed.
Here is the Module code.
Public Function RunExcel()
Dim oExcel As Object
Dim afe As Excel.Application
Dim Filename As String
Filename = Forms!Startup!txtAddFile.Value
'oWB.Open (Filename)
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open (Filename)
oExcel.Visible = True
With oExcel
.Range("A:A,B:B,C:C,D
,E:E,F:F,G:G,H:H,I:I,J:J,K:K,L:L,M:M,N:N,O:O,P
,Q:Q,R:R,S:S,T:T,U:U,W:W,Y:Y,Z:BQ"). _
Select
.Range("Y1").Activate
.Selection.Delete Shift:=xlToLeft
.Range("A1").Select
.ActiveCell.FormulaR1C1 = "Item_name1"
.Range("B1").Select
.ActiveCell.FormulaR1C1 = " Item_name2"
.Range("C1").Select
.ActiveCell.FormulaR1C1 = " Item_name3"
.Range("D1").Select
.ActiveCell.FormulaR1C1 = " Item_name4"
.Range("E1").Select
.ActiveCell.FormulaR1C1 = " Item_name5"
.Range("F1").Select
.ActiveCell.FormulaR1C1 = " Item_name6"
.Range("G1").Select
.ActiveCell.FormulaR1C1 = " Item_name7"
End With
oExcel.DisplayAlerts = False
oExcel.Save
oExcel.Quit
oExcel.DisplayAlerts = True
Set oExcel = Nothing
I would like to know what the problem is first, and when I fix it I would like for the excel sheet information not to be deleted.
I am working with Access 2010. I have a big Access Database that I got when I took the place of someone else. The database has never really worked correctly as I am told. I would like to see if this is a common problem which it is weird that the DB does this crazy stuff.
I have a form that I have an option to upload an excel sheet. When I press the button the excel sheet uploads, it pops up, then when I open the table it should be going to it only uploads some of the data but not all the data, and when I reopen the excel sheet all the data is gone / columns are renamed.
Here is the Module code.
Public Function RunExcel()
Dim oExcel As Object
Dim afe As Excel.Application
Dim Filename As String
Filename = Forms!Startup!txtAddFile.Value
'oWB.Open (Filename)
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open (Filename)
oExcel.Visible = True
With oExcel
.Range("A:A,B:B,C:C,D


Select
.Range("Y1").Activate
.Selection.Delete Shift:=xlToLeft
.Range("A1").Select
.ActiveCell.FormulaR1C1 = "Item_name1"
.Range("B1").Select
.ActiveCell.FormulaR1C1 = " Item_name2"
.Range("C1").Select
.ActiveCell.FormulaR1C1 = " Item_name3"
.Range("D1").Select
.ActiveCell.FormulaR1C1 = " Item_name4"
.Range("E1").Select
.ActiveCell.FormulaR1C1 = " Item_name5"
.Range("F1").Select
.ActiveCell.FormulaR1C1 = " Item_name6"
.Range("G1").Select
.ActiveCell.FormulaR1C1 = " Item_name7"
End With
oExcel.DisplayAlerts = False
oExcel.Save
oExcel.Quit
oExcel.DisplayAlerts = True
Set oExcel = Nothing
I would like to know what the problem is first, and when I fix it I would like for the excel sheet information not to be deleted.