I have an MS Access DB that pulls records from two tables (FYI this is for inventory). Boss has a premade Excel workbook that the information needs to go into. I use a Query to make sure that the data is from where she needs. then i have a VBA to export it out to the excel workbook, but Access says that it is to big.... I have broken it up into 2 Subs() (Sub Aug01 (), Sub Aug02 ()). I need help making it all export out to the same excel workbook. How I have it set right now is it opens the same workbook twice. I can't figure out how to get it to run all on the same workbook... below is part of the code that i use (the only thing that changes is the range for the Excel). I would not mind a loop until the bar-code is null, because all items in the record have a bar-code. :banghead::banghead::banghead::banghead::banghead:
Code:
Private Sub AUG01()
DoCmd.GoToRecord , "", acFirst
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
objXLApp.Application.Visible = True
Set objXLBook = objXLApp.workbooks.Open("S:\newborn screening\Administrative NBS\01 NBS Admin\Items Being Worked on (Matt)\LD4 list\LD4a MM TB Diagnostic - Master.xlsx")
With objXLApp
.Visible = True
.sheets("Aug").select
End With
objXLBook.activesheet.range("A2") = "FY " & Me.[month1]
objXLBook.activesheet.range("A5") = Me.[item #]
objXLBook.activesheet.range("B5") = Me.[Item]
objXLBook.activesheet.range("C5") = Me.[Notes]
objXLBook.activesheet.range("D5") = Me.[Unit Type]
objXLBook.activesheet.range("E5") = Me.[Cost]
objXLBook.activesheet.range("F5") = Me.[Total]
objXLBook.activesheet.range("h5") = Me.[Barcode]
If (Not IsNull(Me.Item.Value)) Then
objXLBook.activesheet.range("A6").EntireRow.Insert xlDown
On Error GoTo errorhandler
DoCmd.GoToRecord , "", acNext
End If
errorhandler:
End Sub
Last edited: