Hi, all. I have an Access form that needs to be exported into Excel and emailed out from Access. I created an Excel spreadsheet that mimics the form's design and layout, and I can export the text boxes from Access into Excel's cells very easily with the following code:
Emailing the spreadsheet is also not a problem. The problem is that there are several check box fields in Access (within frames). For example, fraPO contains a Yes check box and a No check box that the user entering the form's data selects to say if a Purchase Order is associated with this record. i have created chkPOYes and chkPONo within the Excel template that I need to have checked or un-checked based on the value of fraPO on the Access form.
Can you provide me with sample code for this?
Thank you!
Code:
Dim fldDate As DAO.Field
Dim xlApp As Excel.Application
Dim xlWrkBk As Excel.Workbook
Dim xlSht As Excel.Worksheet
Dim myRec As DAO.Recordset
Dim currec As Integer
currec = Me.Number.Value
Set xlWrkBk = GetObject("C:\My Documents\Template.xls")
Set xlSht = xlWrkBk.Worksheets(1)
Set myRec = CurrentDb.OpenRecordset("Contacts")
Set fldDate = myRec.Fields("Date")
Do Until myRec.Fields.Item("Number") = currec
myRec.MoveNext
Loop
xlSht.Cells(10, "C") = fldDate
Emailing the spreadsheet is also not a problem. The problem is that there are several check box fields in Access (within frames). For example, fraPO contains a Yes check box and a No check box that the user entering the form's data selects to say if a Purchase Order is associated with this record. i have created chkPOYes and chkPONo within the Excel template that I need to have checked or un-checked based on the value of fraPO on the Access form.
Can you provide me with sample code for this?
Thank you!