#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2015
    Posts
    2
    Rep Power
    0

    Access to Excel Export pulling incorrect field


    In my works microsoft access database I have built a button to export data from a specific form to an excel document. The excel document has it's own calculations built in to pull/distribute the data from the database when the excel document is opened by the click button. As of Friday the code was working perfectly and was pulling everything as expected.

    Today when I came in, the button is no longer pulling the field 'Customer #' to the document, it instead duplicates the information from 'Install Customer #' So for instance, a record with the following information:

    Customer Name: Glowie
    Order #: 1
    INSTALL Customer #: 99
    Customer #: 100

    The above information would pull to excel with the following 4 fields:
    A2 = Glowie
    B2 = 1
    C2 = 99
    D2 = 99

    The code is as follows in access:

    Code:
    Private Sub Command8_Click()
    Dim appExcel As Excel.Application
    Dim wrkBook As Excel.Workbook
     
    Set appExcel = New Excel.Application
    Set wrkBook = appExcel.Workbooks.Open(CurrentProject.Path & "\Formula.xls")
     
    appExcel.Visible = True 
     
    wrkBook.Worksheets("Data").Activate
     
    With wrkBook.ActiveSheet
      .Range("A2").Value = [Customer Name]
      .Range("B2").Value = [Order #]
      .Range("C2").Value = [INSTALL Customer #]
      .Range("D2").Value = [Customer #]
        .Columns("A:H").AutoFit    
    End With
    End Sub

    Please advise why the code would be pulling INSTALL Customer # to C2 and D2.

    Thank you!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2015
    Posts
    2
    Rep Power
    0
    Appears there is no issue with the code, however at some point in time the Access Form we were using had the Install Customer # text box named 'Customer #' so it was pulling the data from that text box, not the database. Changed the text box name to text0000 and it works fine now.
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,553
    Rep Power
    4549
    Thank you for posting what you found out about your problem.
    ======
    Doug G
    ======
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo