Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2010
    Location
    1000 Islands - Canada
    Posts
    3

    Using value entered as query criteria

    I have an Access 2007 form CLUB INFO which uses a query function to populate fields using data from a table called [mbrlist] with the count of members who have spent less than $400.

    The query function I use to populate the CLUBINFO field clubinfo.[CasualPatron] looks like: =GetQueryValue("SELECT count(*) from [mmbrlst] where [FBSpnd]<400")

    I would like to be able to substitute ”<400” with “<[lowspend]” and be able to enter a value into clubinfo.[lowspend] so that the criteria for the query could be based on this value.

    However, [Mmblist] and the control source table for the CLUB INFO form [clubinfo] do not share any common fields so I have nothing with which to join the two tables.

    I want to enter the amount into ClubInfo.[lowspend] once and change this value from time to time.


    I do not want to use a parameter query which would call for input each time ClubInfo opened.

    Thanks

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    If I understand your question (and I'm not sure I do) - you seek to have the criteria of query to be semi permanent - and that a user can change it from a screen.

    One approach is to make a table just for this value. You can have it appear in a form independently as its own little subform. The criteria of the query can be based on this value.

  3. #3
    Join Date
    Aug 2010
    Location
    1000 Islands - Canada
    Posts
    3
    Hi NTC - thanks for the response:

    The query function that I am using to populate the CasualPatron field on the form CLUBINFO is: GetQueryValue("SELECT count(*) from [mmbrlst] where [FBSpnd]<400")

    This function returns a value from the bold query between the two double quotes and places this value in the [CasualPatron] field in clubinfo (I enter this function as the ControlSource for the Field.

    The table Clubinfo is the Record source for the form CLUBINFO. However, the table clubinfo and the table mmbrlst do not share a common field to join the two tables. Therefore, if I replace <400 with <[lowspend] in the query function above, I get an error. I need a way to get the query to use the value in the field clubinfo.[lowspend].

    I hope to be able to change the value in [lowspend] to in order to increase or decrease the count generated by the query.

  4. #4
    Join Date
    Aug 2010
    Location
    1000 Islands - Canada
    Posts
    3

    Resolved

    I realised that I do not need a common field in the function. All I had to do was list the table as an additional record source. This made the fields from both tables available to the function. Since I am merely doing a count of the records in one table and only have one record in the second table the function returns what I require. It's easy when you know how!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 03-09-2010, 07:00 AM
  2. create a query to find names not entered
    By tomClark in forum Queries
    Replies: 4
    Last Post: 02-24-2010, 10:58 AM
  3. Replies: 5
    Last Post: 08-05-2009, 12:13 PM
  4. Query Criteria
    By MrMitch in forum Queries
    Replies: 0
    Last Post: 03-31-2009, 02:25 PM
  5. one date entered to hit 3 fields in one table how?
    By techexpressinc in forum Queries
    Replies: 0
    Last Post: 12-10-2008, 10:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums