Results 1 to 5 of 5
  1. #1
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33

    Variable from Parameter Query


    Is there a way to assign the data from and Input box of a parameter query to
    a variable?

    Here's the parameter for the query;
    ((DatePart('ww',[dbo_Hse.ExpDate],2,2))=[Enter Week Number]))
    I would like to assign the "Week Number" the user enters to a variable.

    Thanks for any and all suggestions

    OCC

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    not sure, but you might want to try running the query from a form and instead of using an input box, use a control as criteria instead. throwing data from a control to a variable memory is simple one liner code

  3. #3
    KathyL is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    94
    I’m thinking it would be good to have the [Enter Week Numbers] as a separate column in the query, and give it an expression name, like UserWeekNumber: [Enter Week Number]
    Then I think you might be able to access that column as a calculated field and put it on a form, even invisibly.
    And your original calculation could also refer to the expression name.

  4. #4
    OldCityCat is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    33
    Sorry If I didn't explain myself very well,I try again'
    My query works as expected It prompts me for the week number and returns the data I need.

    What I need is to assign that week number that was just used in the query to a variable.

    I need to use the same week number to check for records in a table before I appended new records.

    I hope this makes sense.

    Thanks
    Gil

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you can not assign the data from and Input box of a parameter query to
    a variable. but you can pass the data from a variable to a query.

    Why don't try it on the other way, save the date to a variable (input through textbox or messagebox), then run you query with this variable, the use the same variable to check for records in the other table before you append new records.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  2. Create a variable from a query created in VBA
    By kaelcarp in forum Programming
    Replies: 4
    Last Post: 06-11-2010, 09:13 PM
  3. Using a field as a variable in a query
    By Shadow2K9 in forum Queries
    Replies: 1
    Last Post: 06-10-2010, 07:38 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Passing a value from a variable to an update query
    By MUKUDU99 in forum Programming
    Replies: 0
    Last Post: 08-24-2008, 11:14 PM

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