Variable from Parameter Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gchichester
    New Member
    • Aug 2010
    • 7

    #1

    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

    Gil
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Edit the query and in the criteria for that field
    type
    [Please Enter The Week Number]

    the query will treat that as a field name that doesn't exist and will popup a message box asking for it's value to be entered


    I will let you figure out how to apply that to your expression.
    It is quite easy if you think about it

    Comment

    • gchichester
      New Member
      • Aug 2010
      • 7

      #3
      I'm must be missing something, 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 use the same week number to check for records in a table before I appended new records.
      I hope this makes sense.

      Thanks
      Gil

      Comment

      • Jerry Maiapu
        Contributor
        • Feb 2010
        • 259

        #4
        Create a text box on form so that user's can enter the week number from the form. That value can be access by the query to filter the query records.

        Hereafter you can store the text value in a variable (using Vba).

        To achieve this, replace
        Code:
        [Please Enter The Week Number]
        in the query by
        Code:
        Forms![Your Form name]![the text box name]
        .

        Create a cmd button on the form so that when clicked can open/run the query based on the week no value entered.

        Something like:

        Code:
        DoCmd.OpenQuery "Your query name", acViewNormal
        Hope this helps

        Comment

        • Delerna
          Recognized Expert Top Contributor
          • Jan 2008
          • 1134

          #5
          Edited: I realised I wasn't understanding the question.

          I think you will need to supply a more detailed description of what you are trying to do. As Jerry is alluduing to, you will probably need to do it through VBA but you don't supply enough detail to give a fuller answer.

          Comment

          Working...