473,385 Members | 1,317 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,385 software developers and data experts.

How to make a chosen field from table a value for query criteria?

Hello,

I created a table with only two columns "Month" and "FY". The table has only one row. The purpose is to change two cells content:

- once a month ("Month") and
- once a year ("FY")...

... as an admin. My idea was to take these values and use them as criteria in a query that could show me only records for the month chosen by me in "Month" column.

How make the query recognize the value of the "Month"?
Usuall "directory" like:

[tbl_CurrentMonth]![Month]

simply does not work...

I would really appreciate some suggestions!

Thanks !
Oct 18 '10 #1
7 1028
nico5038
3,080 Expert 2GB
There are two options:
1) JOIN the table with the table you want to "filter" and change the ON option into a comparison with the Month and Year field.
2) Create a startdate and enddate function to get the year and month and use a "BETWEEN fncStart() and fncEnd()" in the query.

Getting the idea ?

Nic;o)
Oct 18 '10 #2
Hi,

Is there a simpler option? I mean is there a way to show directly which cell in my table I want to use as a variable? Following my "logic" is there a way to show Access directly the "coordinates" of the value?

For example something like this:

=[tbl_CurrentMonth]![Month]![ROW1] ???

Thanks.
Oct 18 '10 #3
nico5038
3,080 Expert 2GB
For a "direct" comparison there's the JOIN.
The only other option I see is to create a query with a Month and FYear column and to JOIN the single row table by that.
The "cost" is in general the fact that the result won't be editable.

Nic;o)

PS: Change the name of the Month field, as it's a reserved word (and also an Access function...)
Oct 18 '10 #4
Ok,

And what if I want to use a value from table in a form so that when a user opens a form such a value is already fetched as "default" ? How to fetch the value to a form?

Thanks.
Oct 18 '10 #5
nico5038
3,080 Expert 2GB
Use the query as the form's recordsource.
(That's why I warned about the query in my previous comment)

Nic;o)
Oct 18 '10 #6
Ok, I'm getting the idea, one more beginner's question:

how to:

"...create a query with a Month and FYear column and to JOIN the single row table by that."

?
Oct 18 '10 #7
nico5038
3,080 Expert 2GB
The easy way is to place both tables in the graphical query editor and to JOIN on some field.
Next switch to SQL-text mode and change the field1 = field2 into e.g.
Month(Datefield) = F_Month and Year(Datefield) = FMonth

The cost is the fact that Access can't represent this in the grahical query editor and will issue warning messages !
Thus I prefer the function approach :-)

Nic;o)
Oct 18 '10 #8

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

Similar topics

4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
2
by: zion saal | last post by:
i wont to make a field in a select query to put two fields from a table into one field or control like " Expr1:&' '& " but the problem is thet "field1" is a Currency format and field2 is a...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
5
by: epost2 | last post by:
Hi all, I`m an Access newbie and could use some help here. I`ve made a query and it works fine. Now I want the query to display the value for a field only if the value is > 0. I`ve tried...
3
by: stevecat | last post by:
Hi there, I have created a form, "search" and a query "search_product". The query returns the product information based upon the criteria for three of the fields, author, title or isbn. The field...
3
by: ericargent | last post by:
Hi I'm using Acces 2003 I have Query where the several parameters for the criteria are supplied from a form. One parameter source is a combo box. What I am trying to do is if: An item is...
3
by: sfrvn | last post by:
I have searched high and low and cannot find an answer to my problem. So now I turn to the collective genius of this newsgroup. Over-simplified examples This query criteria for field works:...
4
natalie99
by: natalie99 | last post by:
Hi All :) I am trying to stipulate rules for the return of a pricing value in Access. I know this should be very easy, I simply cannot seem to make my expressions work! The two tables have...
1
by: Coll | last post by:
I have a database that produces different "cuts" of data for the user to export into excel. The database essentially opens queries using different criteria to filter the data as the user wants it....
2
by: KimmyG | last post by:
I'm using MS SQL Server Visual Studio 2008. Thanks.
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.