Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Posts
    98

    Unanswered: Exporting Date field from Ms Access form to Excel shee

    I am trying to export date field from MS ACCESS form to Excel Sheet through following VBA code but it prints as a number such as 41795 instead of actual date on access form.

    Dim objexcel As Excel.Application
    Dim objworkbook As Excel.Workbook
    Dim objxlsheet As Worksheet
    Set objexcel = CreateObject("Excel.Application")
    ''Set objworkbook = objexcel.Workbooks.Open("C:\MSEXCEL_TEST" & "\" & "test.xlsx")
    Set objworkbook = objexcel.Workbooks.Open(CurrentProject.Path & "\" & "HERCA_TWTTP_FORM.xlsx")
    Set objxlsheet = objworkbook.ActiveSheet




    objxlsheet.Cells(11, 4) = Me.dateIdentified
    objxlsheet.Cells(4, 1) = Me.txtProblem
    objxlsheet.Cells(4, 10) = Me.txtOperation
    objxlsheet.Cells(11, 13) = Me.txtOperatorName
    objxlsheet.Cells(11, 30) = Me.txtInterviewerName
    objxlsheet.Cells(13, 13) = Me.dateCompleted
    objxlsheet.Cells(12, 13) = Me.txtTeam
    objexcel.Visible = True
    Set objexcel = Nothing
    End Sub


    HOW CAN I CHANGE IT TO ACTUAL DATE.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try:
    Code:
    objxlsheet.Cells(11, 4) = Format(Me.dateIdentified, "yyyy-mm-dd")
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •