473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing variable from table to query

I have queries (4) that all use some form of date range to process segmenting a customers value. I use a format of YYYY-MM for 100% of these queries. I wrote all four queries to have user input to enter the dates and they all work perfectly well. What I want to do is automate process. I already have an information table that I use as visual hint for manually entering the proper dates. My question, can I use a form or table that essentially duplicates my information table to allow the query to pick up the proper YYYY-MM. If yes, I would greatly apprciate any help/code.
Oct 5 '10 #1
1 971
danp129
323 Expert 256MB
Do you just need to format the date? Such as msgbox(New Date(2010, 1, 1).ToString("yyyy-MM"))

Or do you need a hashtable:
Expand|Select|Wrap|Line Numbers
  1.         Dim DatesHashtable As New Hashtable
  2.  
  3.         'generate fake mock data for key=UserSubmittedDate, value=DateIWantToUseInstead
  4.         DatesHashtable.Add("1/1/2010", "2010-01")
  5.         DatesHashtable.Add("2/1/2010", "2010-01")
  6.         DatesHashtable.Add("3/1/2010", "2010-01")
  7.         DatesHashtable.Add("4/1/2010", "2010-02")
  8.         DatesHashtable.Add("5/1/2010", "2010-02")
  9.         DatesHashtable.Add("6/1/2010", "2010-02")
  10.         DatesHashtable.Add("7/1/2010", "2010-03")
  11.         DatesHashtable.Add("8/1/2010", "2010-03")
  12.         DatesHashtable.Add("9/1/2010", "2010-03")
  13.         DatesHashtable.Add("10/1/2010", "2010-04")
  14.         DatesHashtable.Add("11/1/2010", "2010-04")
  15.         DatesHashtable.Add("12/1/2010", "2010-04")
  16.  
  17.  
  18.         Dim userValue As String = "6/1/2010"
  19.         MsgBox("The date to enter for '" & userValue & "' is " & DatesHashtable(userValue))
  20.  
Oct 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michelle | last post by:
Hi all, I have a query that scans huge table consists of 8 or more millions records. The funny thing is that if I use the query with local variable, the query takes more than 1 minutes,...
1
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to use a make table query to pull the last transactionID, so I can use an append query to reset the transactionID to the next...
4
by: dixie | last post by:
I want to write a query where one of the two tables in it is variable and its name is picked up from a text box control on an open form. The query is very simple and is only a select query with...
2
by: Kathy Krizl | last post by:
I'm probably doing something stupid, but I have a make table query. One of the tables I reference has some check box fields in it. Their Data Type is Yes/No, their field property format is Yes/No,...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
4
by: ken | last post by:
Hi, I use this command to run a make table query without opening it... CurrentDb.Execute "make table query name" Access tells me that it can't execute a select query...? Its a make table query...
11
by: kennthompson | last post by:
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result =...
3
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
2
by: BulbFresh | last post by:
Hi, I'm a novice Access user and have a simple question but can't seem to find the answer. I have tables imported and named by the user on import e.g. January. I then need to run a query on the...
1
globalguideline
by: globalguideline | last post by:
Hi all here at forum. I am working to find out some solution to access a web page in PHP that is showing information on the bases of given argument in query string variable. My problem is this that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.