Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002
    Posts
    192

    Unanswered: Returning a value from an Access form

    Are there some ways to return a value from an Access form? The ways i'm aware of seem clumbersome. Maybe someone will know of a better way to do this.

    1. Form 1 calls Form 2
    2. Form 2 returns a value to form 1

    A)
    - Create a global variable and set the value
    - Have a timer event look for a value set in the global (runs in form 1)

    B)
    - Pass in the name of the calling form via openargs to form 2
    - form 2 writes the return value back to a hard coded Field name based on the dynamic form name passed in viz openargs

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Just passing the values from form to form is how I would handle this situation.

    I dont know why you need the second form to actually open unless the user is going to select a value. If the form doesnt need to be opened you should be able to use the code below... if the user has to have that form open then let me know and I will try to write some code to allow for that situation.

    Code:
    Private Sub yourobjecthere_Click()
    
        yourvar = [Forms]![yourformnamehere]![yourobjecthere] 'put form 2 value into variable
        yourobect.value = yourvar 'set the value of object to the variable
    End Sub
    Hope this helps some,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can also pass an object reference from one form to another: this old example uses this method to allow a single date-select/calculate form to be shared by dozens of date textboxes on the calling form: the date-select form "knows" which textbox object it is supposed to update thanks to the object reference. the code is somewhat inelegant since it requires a call to a setup routine in the date-select form ...but it works.

    izy
    currently using SS 2008R2

Posting Permissions

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