+ Reply to Thread
Results 1 to 3 of 3

Add criteria to an existing query via VBA

  1. #1
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Add criteria to an existing query via VBA

    I'm having some difficulty adding a criteria to a field in my query via a VBA macro. My aim is to insert a date range criteria into the field "DATE: REC_DATE" in a query labeled "Usage -1". Unfortunately, I'm having some issues in doing so. I currently have the criteria being saved in a field on an imported table but I'm unsure of the best way to set this criteria for this field. Following is where I've gotten so far:

    Please Login or Register  to view this content.
    Any help would be appreciated.


    Thanks

    Met

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,176

    Re: Add criteria to an existing query via VBA

    use a form, with txtStartDAte and txtEndDate.
    so you dont have to keep entering data over & over.

    then the query: qsMyQuery is:
    select * from table where [DateField] between forms!fMyForm!txtStartDate and forms!fMyForm!txtEndDate

    so all you do is call:
    docmd.openquery "qsMyQuery"

  3. #3
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Re: Add criteria to an existing query via VBA

    Thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Append CSV query to existing table. Is it possible?
    By DMA in forum Excel General
    Replies: 4
    Last Post: 03-11-2021, 04:19 PM
  2. [SOLVED] Power Pivot/Query Convert Existing Table to Query
    By trisoldee in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-23-2019, 04:27 PM
  3. Replies: 7
    Last Post: 07-07-2014, 09:48 AM
  4. Add to existing query, add table, update sum column
    By randell.graybill in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2011, 08:47 PM
  5. PivotTable query and overwriting existing data
    By rsilayan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2008, 12:53 PM
  6. How to change an existing query
    By Gireeshm in forum Excel General
    Replies: 2
    Last Post: 07-19-2006, 08:40 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1