Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
 
Home > Forums > Access
 
Access Forum

Welcome to the Microsoft Access Forum. Access is by far our most popular topic here at Computer Learning Zone. This forum is for everyone to read but only students can post here. If you'd like to become a student, all you have to do is enroll in one of my courses, which you can do for as little as $1. After you create a logon, you will have full access to the Forums.

Subscribe to this forum and receive an email update whenever new posts are added. You will also be notified by email if any conversations you are involved in receieve new comments. Yes, even non-students can subscribe to update notifications.

NEW: Access Developer Students, make sure you subscribe to the Developer Student Forum.

Click Here to Post a comment and start a new discussion

Please read the FORUM RULES before posting.

 

Pass Value to Parent Form Upload Images   Link  
Dg Ewing 
4 months ago
I was struggling to create code that would pass a value from a subform [IcwID] to the mainform .  

One of the attempts used the subject syntax/code which did indeed pass the value from sub to main.

But for some reason, when you enter any field on the main it treated that record as if it was a new record and would give a warning that the changes you were requesting would not be done because they would create duplicate index, primary key, or relationships.

Any Ideas on how to communicate that it is not a new record
Scott Axton
4 months ago
Are the pictures in the previous post relevant here?

Typically the form -> subform  setup is more of a top down situation.  You are producing records in tables in the subform that are related to the parent or main form.  I don't recall any teachings by Richard that involve passing data backwards from a subform to the parent form.

If you are getting that error it is because you are likely directing Access to insert a record using the ID field which you can't do if it is an auto number field. That is what causes the duplicate value error.
Scott Axton
4 months ago
To accomplish what you are speaking about,  you will more than likely have to have a separate form. One that has your data that is currently in your Subform as the "parent" and relate it to the data that is currently in your parent form as the subform.
Richard Rost
4 months ago
What do you mean by "pass a value?" What are you specifically trying to do? Walk us thru the steps.
Dg Ewing
4 months ago
I accomplished what I wanted to do, and that was covered in other  post.  I have a main form with 5 subforms.  The main form gives me the member record (members of the Ewing MDKA [most distant known ancestor] Project--900+)  subform 1 provides the DNA kit info, sf 2 provides relationship to me and the amount of shared DNA and #ofSegments, sf3 provides who the MKDA(s) are, sf 4 gives urls to various genealogical sites, and sf5 provides who they are ICW (in common with) from IcwT.  

I many times want to click on the Match ID [IcwMemID--foreign field in IcwT = MemID on mf and MemT key/autonumber] to see the member info of the ICW person, I struggled getting my code to work, and finally did after 3 frustrating days.  The issue was that I need to reqry, refresh, repopulate the main form rs if I had previously did a search.  On a fresh load, everything worked fine, it wouldnt if I had down selected /filtered .  see my 1st discussion for all the uglies.
Richard Rost
4 months ago
Gotcha. It's just difficult to envision what's going on without understanding the context of your database.
Dg Ewing
4 months ago
but the me.Parent!MemId=me!IcwID created what I wanted, it populated the mf with the MemID equaling the IcwMemID from the sf, but it also thought that I was trying to add (duplicate) the entire record .  I don't know why it didnt work or how to fix, as that code is pretty simple (at first glance) and my other attempt finally worked
Private Sub IcwMemID_Click()
     Dim strsearch As String
     Dim passvalue As String
    
     MsgBox [Forms]![A__MDKAMemExtMainF]![A_IcwInputF]!IcwMemID
  'to test if IcwMemID was captured

     passvalue = Me!IcwMemID
' to test if passvalue was set to IcwMemID value
    
     strsearch = "SELECT * from A_MemberT"
    
     [Forms]![A__MDKAMemExtMainF].RecordSource = strsearch
    
    
     MsgBox passvalue
' to retest after using the [Forms] cmd above  
    
   DoCmd.OpenForm "A__MDKAMemExtMainF", , , "MemID =" & passvalue
'was too tired and frustrated to find out why  the above w "MemID = "& IcwMemID didnt work
    
End Sub
Dg Ewing
4 months ago
btw, I made up the [Forms]![A__formname].RecordSource = strsearch.....it was the only way I could figure out how to repopulate, reqry (although I dont use a qry--the main form gets data from MemT) or  a refrsh.....

This is my only "signature" coding....I am sure that it has been used by many , but I created it without copying ...
Richard Rost
4 months ago
The problem is without seeing your database - or at least screen shots - all of your form and field names are pretty much meaningless and confusing. Read that post that I mentioned earlier: Context. If you can simplify things and express them in terms that I can relate to (customers, orders, etc.) then it makes it much easier to help you. I have no idea what [Forms]![A__MDKAMemExtMainF]![A_IcwInputF]!IcwMemID is.
Dg Ewing
4 months ago
I think it is code that reads the value of IcwMemID,  on the sub form A_IcwInputF which is on the main form A__MDKAMemExtMainF.....Well I know it is code that works because the MsgBox  returned only  the number of IcwMemID.

Wow maybe I have two signature codes...
Dg Ewing
4 months ago

Add a Reply

Show All Comments

Start a NEW Conversation
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 

You may want to read these articles from the 599CD News:

12/4/2021Hangman!
12/3/2021Access Beginner 2
12/3/2021Access Beginner 2 Lessons
12/3/2021Access Beginner 2
11/30/2021Import Multiline Cells
11/30/2021Adam's Access Games
11/29/2021Prevent Close
11/28/2021Random
11/22/2021Currency Symbols
11/13/2021Access Developer 36
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: microsoft access forum  PermaLink