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

    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

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

    - 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
    Nashville, TN
    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.

    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,
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting by Patriot Designs

  3. #3
    Join Date
    Dec 2002
    Préverenges, Switzerland
    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.

    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