Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Unanswered: Pass variable to query from input box

    More Access and SQL stuff.

    I have an input box that I am using for a query def for executing a stored procedure to SQL. I want to use that same user - input box variable for a query being run on the same report.

    How can I pass it to the query?


  2. #2
    Join Date
    Nov 2003
    Posts
    300
    Or, another way to look at it is, An input box pops up for the user to input some required information, how can I cache or keep this information for use in a query to run that also requires the same information?

  3. #3
    Join Date
    Nov 2003
    Posts
    300

    Question

    I'll try this again with some examples:

    Have a report. It runs some vba code when the report opens. The vba executes a MS SQL stored procedure to put data in SQL tables for the remaining part of the subreports in the report.

    EXAMPLE vba:

    qdef.SQL = "EXEC spMYSTOREDPROCEDURE " & InputBox("Enter ID")

    So, when you run the report, it asks for the ID.. Enter ID..
    The user enters in "12345"

    What I want to be able to do is when the user enters in "12345", I want to be able to SAVE, or cache or use that data, 12345 in another query in the same database.

    how can I do this?

    Sort of like when you have 3 subreports that require user input of a "ID", as long as the user input is the same = [Enter ID] on all 3 queries for the subreport, it will ask the user to [Enter ID] only once and the other queires will use the same user data for the other 2 queires.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use a form as the intermediary and then pull that value nto the query using
    forms!myformname!mycontrolname

    When presented with this sort of problem Actually I tend to use a form that acts as the switchboard with the relevant parameters on. when you first open up the form you set valid defaults, and a snother form which does the data capture & validation. once the user has set valid data set the values in the switchboard using the same style the values a are posted either in the accept dialog button or however you style you want it.

    forms!myswitchboard!mycontrol.value = thiscontrol
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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