473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
1 2326
twinnyfo
3,653 Expert Mod 2GB
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

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

Similar topics

10
by: Alain Guichaoua | last post by:
Good evening to all Here is my problem : I have a form with a subform. They are linked. When I open the form I would like the subform to reach its last record. I tried the method...
4
by: Stuart | last post by:
Hi all, I'm trying to make a form that lets the user enter a name into a text box, and have the first record that matches that name be selected in a datasheet subform. For example, say the...
3
by: Uwe Range | last post by:
Hi to all, I am displaying a list of records in a subform which is embedded in a popup main form (in order to ensure that users close the form when leaving it). It seems to be impossible to...
0
by: Alienz | last post by:
hiya! I wanted to make a multiple selection drop down list and I found the easiest way to do this was by creating a subform linked to a table with 2 values, the 1st value links to the main form...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
0
by: (Pete Cresswell) | last post by:
I've got a few subforms, each with an accellerator key assigned. When the user presses, for instance, Alt+2, the focus shifts to subform "2". This works OK once the user has selected a record...
1
by: Drum2001 | last post by:
Hello All, This seems like it would be simple. Is there a way to have an "After Update" event from Subform1 trigger an "add new record" on Subform2? I see posts to go from Mainform to...
2
by: mnms | last post by:
Hi, I'm trying to create an "overview" form. And I haven't been able to figure out how to get Access to do what I want yet. Basicly what I want, is to populate a subform based on a field...
5
Seth Schrock
by: Seth Schrock | last post by:
I have a form with a subform. To save time, I have set several of the main form controls to have default values so that I don't have to edit them most of the time. The subform is often the first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.