Results 1 to 6 of 6
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Opening another form, displaying data from the previous one.


    On the simple attachment. There is a button "Go to form2".
    a. On form1 there is one field named "txtID" with one record "Politics".
    b. On opening form2 the word "Politics" must appear in the one field named "txtSubject" on form2, before typing anything.
    c. Multiple forms will open form2, a lookup expression on form2 to form1 is not what may work.
    d. All forms that will open form2 will have a field "txtID", what is in this field should display in the unbound field "txtSubject" on form2.

    Any VBA code or any other solution will be appreciated.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Several ways for forms to pass data to other forms. One way is with OpenArgs. https://learn.microsoft.com/en-us/of....Form.OpenArgs
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    No. Put in a couple of hours. Did not succeed. Downloaded clips on Openargs. I tried to test what you referenced me.
    a. I wish something easy like the "=Parent!OrderID" will work, if it can, tell me. Saw this on your reference.
    b. I understand Openargs a bit but I would like the word "Politics" if selected on my form1 to be inserted and then displayed in an unbound form2.
    c. If There are three records in form1,table1. The record that is open that field must be inserted and displayed in the unbound field on form2.


  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    In future, post what you tried rather than saying you couldn't get something to work. I don't use macros, embedded or otherwise, so for button click event & OpenArgs method:

    Code:
    Private Sub Command2_Click()
    DoCmd.OpenForm "Form2", , , , , , Me.Text0
    End Sub
    form2 Load Event
    Code:
    Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then Me.txtSubject = Me.OpenArgs
    End Sub
    EDIT - I would probably change to the following (or something similar in order to deal with situation when form is on a new record)
    Code:
    Private Sub Command2_Click()
    If Me.NewRecord Then 
      Exit Sub '<<< or open without using OpenArgs?
    Else
       DoCmd.OpenForm "Form2", , , , , , Me.Text0
    End If
    End Sub
    Last edited by Micron; 09-23-2022 at 09:42 AM. Reason: code edit
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Perfac's Avatar
    Perfac is offline Expert
    Windows 10 Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618
    Thank you very much.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You're welcome.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-18-2021, 10:43 AM
  2. Replies: 9
    Last Post: 03-01-2017, 10:00 AM
  3. Replies: 3
    Last Post: 02-25-2015, 04:48 PM
  4. Displaying Previous Week's Data in Subreport
    By mejia.j88 in forum Reports
    Replies: 3
    Last Post: 06-30-2012, 01:07 PM
  5. Replies: 1
    Last Post: 12-21-2011, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums