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

    Access 97 Queries (97 SR1)

    I need to put a variable into the query design criteria box. Does anyone know the syntax to call a variable or a method in which to call this variable? So far I have been only able to put something in quotes, or sqaure brackets and netiher works.

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

    Re: Access 97 Queries (97 SR1)

    Ok, let's get some more information.
    Where is the variable stored? on a form, in a table ?
    When you pass this variable, is it going to a query behind a form, report ?
    That may help some.

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

    Re: Access 97 Queries (97 SR1)

    Sorry for not being clear enough. The variable is declared in a standard module as public. I have a login form that sets the variable (strRegion) from one of the controls on the form. I then open another form and want to use this variable in the recordsource query to limit the recorset. I have tried to enter the variable name in the query design criteria block but that doesn't work. Setting a debug on the variable returns a good value so I know that the variable is being set properly. Got any ideas what I am doing wrong.

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

    Re: Access 97 Queries (97 SR1)

    You can't reference global variables in a query. There are a couple of ways around this, but the simplest is to create a function that returns the value of the global variable and use that function in your query.
    Charlotte

  5. #5
    Star Lounger
    Join Date
    Sep 2001
    Location
    SC, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access 97 Queries (97 SR1)

    Forget the variable. If there are only a few regions, have command buttons named for each region, that run a macro that opens your form where Region=RegionName. If there are too many regions, then use a form where the user enters the region as a parameter and clicks "okay". Let this "okay" button run a macro which opens your form where Region=value from textbox on parameter form. Let the macro close the parameter form after it has opened the recordset form.

Posting Permissions

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