Copy data from Access to the next row in Excel
- by edmon
I have a MS Access database for a small Hotel. On the main form I have Guest Information fields...(Name, Address, Phone#, etc). I also have an Excel file that keeps track of bookings for the Hotel. The following code takes the Guest information from my form in Access and populates the labeled cells in my Excel file.
Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("Y:\123files\E\Hotel Reservation.xls")
objXLApp.Application.Visible = True
objXLBook.ActiveSheet.Range("B2") = Me.GuestFirstName & " " & GuestLastName
objXLBook.ActiveSheet.Range("C2") = Me.PhoneNumber
objXLBook.ActiveSheet.Range("D2") = Me.cboCheckInDate
objXLBook.ActiveSheet.Range("E2") = Me.cboCheckOutDate
objXLBook.ActiveSheet.Range("G2") = Me.RoomType
objXLBook.ActiveSheet.Range("H2") = Me.RoomNumber
End Sub
Is there a way to, move to the next row in my Excel file, for a new guests info?
EX. I take my first guests info and it populates row 2 of my Excel file. For my next guest it will populate row 3 of my Excel file and so on....