Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2008
    Posts
    20

    Unanswered: Selecting and Copying Records VBA

    Hi Guys,

    I am now trying to search for records that fit criteria from a single table and copy them and pasting them into a spreadsheet. I currently have:
    (Where do i go next)


    Private Sub Command22_Click()
    Dim ExcelApp As Object


    DateFrom = InputBox("Please Enter From Date")
    DateTo = InputBox("Please Enter To Date")
    Person = InputBox("Please Enter Name")


    Set ExcelApp = CreateObject("Excel.Application")
    ExcelApp.Workbooks.Open ("C:\Users\Andy\Documents\Documents\efficiencyrepo rt.xls")
    ExcelApp.Visible = True
    ExcelApp.UserControl = True

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by pundabuyer
    Where do i go next
    Here would be a good spot:
    http://www.dbforums.com/showpost.php...81&postcount=4
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Sep 2008
    Posts
    20
    I have found some code that contains this:

    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    But when ran i get an error saying user defined type not defined

    What does DAO mean why am i supposed to use it?

  4. #4
    Join Date
    May 2008
    Location
    Raleigh, NC
    Posts
    151

    DAO refers to

    Data Access Object. You are probably missing it in your references. While in the VB editor go to Tools, References and add the Microsoft DAO n.n Object Library. Check out the attachment in the post that Pootle Flump references in the below post. It will show you all the code that you probably need.
    --If its free, take it for what its worth!

  5. #5
    Join Date
    Sep 2008
    Posts
    20
    Fantastico!

    I have managed to get info from a table into Excel ! However, I ran it on an existing table called Individual Members and it gives me the cannot find table run-time error but when i copy it and paste it and call it table1 instead it workd fine..? is it because of the space or relationships?

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Not sure but I bet I didn't account for spaces in table names in the code. You'll either need change the code or dump the spaces. If possible, do the latter.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Sep 2008
    Posts
    20
    I have a few tables with spaces and they are linked to forms and reportrs etc i cant change the tables names.. Could you take a look at the code please?

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Just where ever there is code reading from tables, enclose all column and table names with [ and ]. So
    Code:
    SELECT [column with space] FROM [table with space]
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Sep 2008
    Posts
    20
    Thankyou all soooo much for your help, you've gave me my weekend back!! thanks

    Andy

Posting Permissions

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