Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Forums > Access
Back to Access Forum    Comments List
Pass Value to Parent Form Upload Images   Link   Email  
Dg Ewing 
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 
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 
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 
What do you mean by "pass a value?" What are you specifically trying to do? Walk us thru the steps.
Dg Ewing 
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 
Gotcha. It's just difficult to envision what's going on without understanding the context of your database.
Dg Ewing 
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 
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 
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 
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 

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
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
PCResale.NET
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
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/28/2024 9:36:05 AM. PLT: 0s