By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

How to add a record in a subform to another subform based on selection of record

P: 1
I have two mainforms which have two subforms

1) Mainform Inventory List with subform Supplierssubform
2) Mainform Supplier List with subform Supsubform

When I select Supsubform record it must automatically requery in Supplierssubform

My code works but it should display the record in the Supplierssubform instead it display the record in the Supsubform where i make my selection when I make my selection it should display in Supplierssubform not in the popup form where I make my selection. Any help, suggestions please

Heres my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub SupplierName_Click()
  2. Dim rst2 As Recordset
  3. Dim rst1 As Recordset
  4.  
  5. Set rst2 = Forms![Supplier List]!Suppliersubform.Form.RecordsetClone
  6.  
  7. 'find the current record
  8. rst2.FindFirst "ID = " & Me.ID
  9.  
  10. Do While Not rst2.EOF
  11. rst2.AddNew
  12. rst2!SupplierName = Me.SupplierName
  13. rst2.Update
  14. Exit Do
  15. Loop
  16.  
  17. rst2.Close
  18. Set rst2 = Nothing
  19.  
  20. End Sub
Nov 6 '17 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 3,284
grampiano,

Welcome to Bytes!

I am not quite sure I understand what you are trying to do, either from your question or from your code. Based on your description, there is only one reference to a different Form, so it does not appear that your Form is trying to make the other subform "do" anything, other than using values for finding an ID.

Additionally, it looks like your code will add a new record if there is already a record that exists that meets the criteria.

Perhaps you can more clearly describe what it is you are trying to do. Please see this post for assistance: Asking Good Questions.

Hope this hepps.
Jan 2 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.