Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 6th, 2006, 10:45 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export Access Paramter Query to Excel

Hello,

I have used Access for quite a while, but I am new to Visual Basic. Right now, I am trying to Automate my database by exporting the results of a parameter query to Excel. The criteria for the parameter query is based on a combo box I have loaded onto the form. How do I execute the parameter query (based on my combo box) and have the data automatically exported to an Excel template I have already created? I would like to automate this as much as possible with the combo box and parameter query. Thanks.

Justin
Reply With Quote
  #2 (permalink)  
Old February 10th, 2006, 08:58 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Please post in Microsoft Office > Access VBA for better results.

You can put the parameter directly in the query in design view. Enter the following sort of code in the Criteria of the field you want to pass the parameters to:

[Forms]![frmMyForm].[cboMyComboBox]

Then use the button to open the form or report based on this query, and the query will go get the parameter from the combo box itself.

The downside is that this version of the query can only be used for this one button. If you want to pass the parameter to one version fo the query for all uses, then you would do this:

Dim stDocName As String
Dim inComboValue As Integer ' assumes PK is integer is being passed
Dim stLink As String

If IsNull(Me.MyComboBox) or Me.MyComboBox = "" Then
   'error handling
   Else
   inComboValue = Me.MyComboBox
End If

stLink = "[MyPK] = " & inComboValue
stDocName = "frmMyForm" 'or "rptMyReport"

DoCmd.Open... stDocName, , , stLink ' in the WHERE section

HTH


mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Access queries to Excel Spymaster Access VBA 2 August 18th, 2006 11:21 AM
Export an Access query to Excel Peter Martin Access 5 June 8th, 2006 06:36 AM
Entering Multiple Parameters in a Paramter Query jjc9809 Access 2 February 15th, 2006 09:36 PM
Export Access Data to a Specific Cell in Excel. VBNoob Access VBA 1 December 14th, 2005 08:25 PM
Export Table from Access to Excel aramchan Access VBA 2 July 12th, 2004 03:20 PM



All times are GMT -4. The time now is 06:03 PM.


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