Copy data from Access to the next row in Excel

Posted by edmon on Super User See other posts from Super User or by edmon
Published on 2011-01-13T16:46:49Z Indexed on 2011/01/13 16:55 UTC
Read the original article Hit count: 171

Filed under:
|
|

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....

© Super User or respective owner

Related posts about excel

Related posts about vba