Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Posts
    63

    Unanswered: Passing stuff from one form to another.

    Hello all,

    I am trying to find out if this is possible:
    Two forms.
    One has a CommentBox which contains any comments previously made (preferably dated) which can be scrolled through and printed as one long record if needed.
    The second is a popup form that allows you to enter a new comment and date for that comment.
    When you click on the button on the second form, the comment and date are ADDED onto the end of the previous comments, possibly with a carriage return for good measure.

    Can it be done, and if so, how?

    I would also like to know how to just pass a numerical value from a similar popup by clicking a particular button to a textBox, but I may post about that later

    Thanks in advance,
    ChrisOfCatford

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    OpenArgs property of the OpenForm method ... AS for your primary question: Yes. And anyway you want to ... You can do a "call back" to the parent form and update the comment that way ... or you can do it thru ADO/DAO with a requery ... There are numerous ways ...
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Sep 2004
    Posts
    63
    Hi M Owen and thanks for your reply,

    Unfortunately I am less well informed than your answer assumed

    Could you explain in more depth please?

    Thanks,
    ChrisOfCatford

  4. #4
    Join Date
    Sep 2004
    Posts
    63
    OK, I figured it out. OpenArgs wasn't going to work because of the way the forms needed to work.

    In the end I found another post using a module to set define the variable. This works fine.

    Only thing is I am using a button (like apply) to effectively paste the variable onto the end of the existing string in the CommentBox. So the code is set in the input form when clicking a button that also closes the form, but then the variable is retrieved in the code for the first form.

    This works fine, but could someone tell me how I can pass the variable to the form with one button on the input form? It just seems to elude me.

    Thanks,
    ChrisOfCatford

  5. #5
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    You could use global module variables or you could refer to the textbox's on the form like:

    Forms![Your_Form]![YourControl1]
    Forms![Your_Form]![YourControl2]

    and concatenate the values like
    Forms![Your_Form]![YourControl1] & " " & Forms![Your_Form]![YourControl2]

  6. #6
    Join Date
    Sep 2004
    Posts
    63
    Thanks TerpInMD,

    That's just what I needed!

    OK so one last bit: I need to have one of these forms pop up, and send a number back to the box depending on which button is clicked in the popup. I can do this, but now I am struggling with how to only use one form popup to allocate these (there are 12 in total).

    I tried passing the refering name by putting it in quotes or not putting it in quotes, but it didn't work correctly.

    This is my starting point:
    Code
    'Main Form:

    Private Sub AA1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim stDocName As String
    Dim stLinkCriteria As String
    Set_Value1 "[Grade1]"
    stDocName = "LevelPicker"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_Command6_Click:
    Exit Sub

    End Sub

    'On the Secondary Form:

    Dim ReferingBox As String
    Dim CompleteReferer As String

    ReferingBox = Get_Value1()
    CompleteReferer = "Forms![Pupils]!" & ReferingBox

    'An Example of one of the buttons.

    Private Sub Y710_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Forms![Pupils]![Grade1] = 10 ' This is the Syntax I am after
    DoCmd.Close
    End Sub

    END CODE

    So I need some way of stringing that all together and then assigning the value to the box rather than having to assign it as above.
    I have seen other examples, but they don't seem to work in this instance.

    Thanks,
    ChrisOfCatford

Posting Permissions

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