Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Exporting from Access to Excel (https://www.askmehelpdesk.com/showthread.php?t=109285)

  • Jul 12, 2007, 11:17 AM
    kenzie416
    1 Attachment(s)
    Exporting from Access to Excel
    Scottgem,

    Here is the sample database & associated excel file relating to my problem w/ exporting from access to excel (thread started in AllExperts.com); you'll need to go into the VBA of the Access database and change the reference to the location of the excel file in order for it to run (I've marked the locations in the code). You should be able to start by clicking on all of the checkboxes in "form1" of the database "dbsample.mdl", and clicking "execute" and it will automatically run the query and transfer the associated fields to excel. Then you'll need to close the spreadsheet before running the query again. Then run the query again by clicking on 2 or 3 of the checkboxes and it should run fine. Then if you run the query again, clicking on all 4 checkboxes, an "error 3190: Too many fields defined" should come back. That's what I'm stuck at.

    Thanks in advance to any help you can provide,
    Heidi
  • Jul 12, 2007, 12:02 PM
    ScottGem
    Found it. The problem was your named range (quer) in the worksheet was set to two columns. It would work as long as only 2 boxes where checked. But once you checked another box. It bombed. I increased the range to the E column and it worked fine.
  • Jul 12, 2007, 12:23 PM
    kenzie416
    I tried increasing the named range (quer) to 8 columns, and it worked for the next time I ran the query with all 4 boxes checked, but it redefined quer to accommodate the 5 columns I needed. When I ran the query again for 2 checkboxes, is again redefined quer for the 3 columns that I needed. Then I ran it again w/ all 4 boxes checked and it bomb. It seems like I can decrease the number of columns needed and it will defined the named range fine, but increasing the number of columns is a problem.
  • Jul 12, 2007, 12:47 PM
    ScottGem
    Ahh I didn't test enough. Something is causing the quer range to fit the exported data. Once its less than 4, it won't allow more than what its set for.

    One solution might be to redefine the quer range when the worksheet is closed. Or after the import is finished.
  • Jul 12, 2007, 01:43 PM
    kenzie416
    I was thinking somewhere along those lines... in fact, I was trying something along those lines earlier today w/ no success. Do you know how to do this in Excel VBA? If not, I can check w/ an Excel expert.
  • Jul 12, 2007, 03:19 PM
    ScottGem
    Try the people at utteraccess.com (another site I hang at). There are a few Excel MVPs there who may be able to help further. My Excel VBA is limited.
  • Jul 13, 2007, 10:09 AM
    kenzie416
    I pinged an Excel guy and got it worked out. Thanks much!
  • Jul 13, 2007, 10:47 AM
    ScottGem
    What was the solution?

  • All times are GMT -7. The time now is 08:18 PM.