Results 1 to 5 of 5

Thread: Queries (97)

  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Queries (97)

    Does anyone know how to put a variable name in the criteria section of a query in design view? I have the query working with static text in the criteria but I can't find what the syntax should be to place a variable in it's place.

  2. #2
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Queries (97)

    Enter your variable surrounded by brackets e.g. [Enter Name]. When the query is run, you will be prompted for the criteria. You can also use wild cards such as Like "*" [Enter Name] & "*"

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Queries (97)

    Thanks Brian, What I have is this public variable "strRegion". It is being set by a control on a previous form. I want this value in the query I was talking about without having to re-enter data. Do you know if there is differnent syntax to park a variable inside a querys criteria box?

  4. #4
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Queries (97)

    Assuming the form is open entering something like: [forms]![yourformname]![strRegion] should work for you.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Queries (97)

    If it is actually a property of the form, that is, a public variable declared in the form's declarations, you can refer to it as [forms]![yourformname].strRegion. I use this technique fairly often with both forms and reports.

    However, if you have declared a global variable in a standard module, you can't refer to it in the query. Instead, you have to create a function to return the value of the global variable and the use that function in the query.
    Charlotte

Posting Permissions

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