Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2004, 09:42 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel Workbook created from Access VBA

Hi All,

I need some help. I have created a form in Access that queries on a persons last name and sends all the info on the last name to an Excel spreadsheet. I want to send multiple people's data to the worksheet---but when i try to do this, I only get 1 person's data at a time in the worksheet. The data of the person before gets over-written. Here is what I have:

glb_Strsql = "SELECT * from DR_SEARCH_TABLE_Mar WHERE last_name= '" & DrName & "' AND FIRST='" & lstFirst.Value & "' and st = '" & lstState.Value & "' and kenwood_territory = '" & lstTerritory.Value & "' "

    Set qdf = CurrentDb.QueryDefs("glb_Strsql")
    qdf.SQL = glb_Strsql
    qdf.Close
    RefreshDatabaseWindow

    DoCmd.TransferSpreadsheet _
        TransferType:=acExport, _
        SpreadsheetType:=8, _
        TableName:="glb_Strsql", _
        Filename:="C:\Documents and Settings\My Documents\My_Search.xls"
        HasFieldNames = Yes


Any help would be greatly appreciated. Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
INSERT into Access Database from VBA for Excel zuerlein Excel VBA 0 June 3rd, 2007 01:51 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
Excel 2003 VBA - Need to open a workbook in a fold bablhous BOOK: Excel 2003 VBA Programmer's Reference 0 December 21st, 2006 02:50 PM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
exporting a workbook from excel to access zisko3 Access 1 February 3rd, 2004 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.