Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15

    Unhappy Passing Data From One Form to Another

    Hello,

    I am a newbie to Access. I have a form where fields are not bound to any table or query. Then I have a command button which opens up a second form (with a subform and a search field) of which the Record Source is a query. When the user types on the search field, the subform data gets filtered accordingly. What I want to do is to populate the fields on the mainform, using the record selected on the subform which is on the second form. Please help! I can provide further information if required.



    Thank you!
    Charlie

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You can fill in any box on a form by using the full path....
    forms!form2!txtBox1= forms!form1.txtBox1

  3. #3
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    Thanks ranman256, for your reply!

    Unfortunately, I already tried your code but it didn't work for some reason. The subform I have on the second form is a datasheet. It gets filtered based on what the user enters in to the text box (search field) I have on the same form. So when a user is double clicking on a specific record to select, there can be other rows on the datasheet which the user is not selecting. For an example, let's assume there are ten rows on the subform and the user types 'Add'. this can filter the records down to three. If the user sees the correct record out of the three currently visible, the user should be able to double click (any other function is also fine) on the relevant row and populate the data of that specific row on to Form 01.

    Thank you!
    Charlie

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    What do you mean by double-clicking on a row? A datasheet view has many fields. Or are you talking about clicking on the record selector?

  5. #5
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    Since the subform is a datasheet, the records are displayed as rows of data. so when the user clicks on one of these rows, I want the specific record to be populated on the main form. I have attached Form 2 Below. On this form 2, you will see a search box and a subform. Subform records get filtered based on what is entered on to that search box. So when the records are filtered, I want the user to click on one of the records and populate Form 01 fields (Not shown here).

    Click image for larger version. 

Name:	Img01.PNG 
Views:	18 
Size:	43.3 KB 
ID:	26296

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You would use the OnCurrent event of the subform - when someone clicks on a record this will fire. Inside that event you can set the main form text boxes to the values on the subform.

  7. #7
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    I was thinking of adding the code to Dbl Click event. When the user double clicks on a specific record, that specific record gets updated on to the main form fields. but I can't seem to get the code right. Sorry, but I am pretty new to Access. Can you please help me with that?

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Either event is fine - as long as you can get it to fire you can use any event.

    Change names as required: Forms!MainForm!fieldname=me!fieldname

  9. #9
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    I tried this code but it did not work. Can it be because of the section in bold (Forms!MainForm!fieldname=me!fieldname)? The subform is placed on another form (Form 02). So when we call the subform, should it be, Me!SubFormName.Form!SubFormFieldName ?

    Edited:
    I just tried it but didn't work. So frustrated!

  10. #10
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You are on the subform, so the "Me" is all that is required. Try adding "Forms!MainForm.Requery" after populating the fields.

    Post your code.

  11. #11
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    Hmm.. That didn't work either. I think I am confusing you. Let me explain again.
    I have a form, let's call it Form 01 which has unbound fields (text boxes). On this Form 01, I have a command button which opens (Pop up) another form. Let's call it Form 02. On this form 02, I have a Text Box which I am using as a Search field and a Sub form control of which the record source is a query. When I type in the text box on Form 02, it filters Sub Form Control data accordingly. What I want to do is for the user to be able to click on a record on the sub form control (which is on Form 02) and Fill Form 01 Data with that selected record data.

    If this is not the standard way to do this, can you please suggest me an alternative?

    Thank you so much!

  12. #12
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I asked you to post your code - not sure what is going on in your code.

    It works for me on the double-click, without the requery, as long as I am clicking the selector button. How are you testing it?

  13. #13
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    Ok. I think I got it right now. Below is my code. The next question is, how can I get all the columns of the record added on to multiple fields on Form 01? Is it by repeating this same step for all the fields I need to populate?

    Private Sub ProcessID_DblClick(Cancel As Integer)
    Forms!Test!ProcessID = Me!ProcessID
    Forms!Test.Requery
    End Sub

  14. #14
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Either that or make your form1 bound to the same recordsource as the subform and repopulate all the fields by requerying the form with the Me!ProcessID as the filter.

  15. #15
    CharlieK is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Oct 2016
    Posts
    15
    Will that work if there are duplicate Process IDs in the query? For an example, subform has the same process step with two different decisions. Those two records will have the same ProcessID.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access not passing data when opening form
    By cardgage in forum Forms
    Replies: 5
    Last Post: 12-11-2012, 06:34 AM
  2. Replies: 3
    Last Post: 07-20-2012, 11:55 PM
  3. Passing Data from on Form to Another..
    By ETCallHome in forum Forms
    Replies: 2
    Last Post: 03-12-2011, 12:26 AM
  4. Form not passing data to query
    By bobfin in forum Queries
    Replies: 13
    Last Post: 08-11-2010, 05:28 AM
  5. Passing data to sequential form fields
    By jeepfamilyva in forum Forms
    Replies: 0
    Last Post: 06-28-2009, 11:04 AM

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