473,385 Members | 1,449 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,385 software developers and data experts.

Find record on parent form based on subform record selection

I have a form and a subform. The subform is displayed as a datasheet. When a user selects a record on the list, I would like the parent for to show the contents of the record selected. Access 2007, has the built in SplitForm, I am creating a 2003 database. I need something similar to the splitform in access 2003.
Dec 7 '07 #1
7 21138
puppydogbuddy
1,923 Expert 1GB
I have a form and a subform. The subform is displayed as a datasheet. When a user selects a record on the list, I would like the parent for to show the contents of the record selected. Access 2007, has the built in SplitForm, I am creating a 2003 database. I need something similar to the splitform in access 2003.
If the subform and main form are linked correctly (parent-child relationship) they should synchronize correctly. So click on the border between the main form and the subform control and reclick on the link fields to make sure they are correct.
Dec 10 '07 #2
Thanks for the reply. The records in the subform are not related to the records in the form – meaning I want the subform to show all records in the table, not only the record that is shown on the form. If I link them, the subform will only show one record, the record that is on the form. How do I show all records on the subform, and only show the record selected on the form?
Dec 10 '07 #3
missinglinq
3,532 Expert 2GB
This is how forms/subforms are intended to be used! If you want all of the records in your subform to show, but only the associated record in your main form to show, you need to reverse your two forms! The recordset for your current subform should be the recordset for your main form and vice vesra!

Welcome to TheScripts!

Linq ;0)>
Dec 10 '07 #4
puppydogbuddy
1,923 Expert 1GB
Thanks for the reply. The records in the subform are not related to the records in the form – meaning I want the subform to show all records in the table, not only the record that is shown on the form. If I link them, the subform will only show one record, the record that is on the form. How do I show all records on the subform, and only show the record selected on the form?
To answer your question:
1. create separate queries for use as the data sources for your form and subform. The queries will determine what is displayed on the form and subform.
2. do not link the form and subform.

<<<If I link them, the subform will only show one record, the record that is on the form.>>>>

The above is not a true statement. If you establish 2 tables in a one to many relationship, for each record on the "one" side, you can display the many records corresponding to the many side....which is really what a subform is for.

If you want to display all records, than use a continuous form. There is no need for a subform. I suggest you take some tutorials available thru this site before proceeding.
Dec 10 '07 #5
Thanks for the quick reply and welcome. I have set the recodset for both the form and subform the same, my problem is the VBA code for the subform. When a user double clicks on a filed on the subform, I want the main form to show that specific record. I just don’t know the code.
Dec 10 '07 #6
puppydogbuddy
1,923 Expert 1GB
Thanks for the quick reply and welcome. I have set the recodset for both the form and subform the same, my problem is the VBA code for the subform. When a user double clicks on a filed on the subform, I want the main form to show that specific record. I just don’t know the code.

Try this (not tested). String datatype was assumed for the common link between the main and subform. If the link is a numeric data type,syntax would change accordingly. Replace object names used for illustrative purposes with the actual name of those objects in your application.
Expand|Select|Wrap|Line Numbers
  1. Private Sub YourField_DoubleClick()     'this code is behind the subform
  2.  
  3.  Dim rs As Object
  4.  Dim strLinkValue As String     'value in link field of the subform
  5.  
  6. strLinkValue =  Me![NameOfLinkFieldOnSubform].Value  
  7.  Set rs = Forms!YourMainForm.Recordset.Clone
  8.    rs.FindFirst "[NameOfLinkFieldOnMainForm] = '" &  strLinkValue  &  "'"      
  9.    Forms!YourMainForm.Bookmark = rs.Bookmark
  10.  
  11. End Sub
Dec 11 '07 #7
Thanks for your help everyone, it worked!!
Dec 11 '07 #8

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

Similar topics

2
by: dbuchanan | last post by:
Hello, I want to open a child form based on the record selected in a dataGridView of the parent form. I want the child form to open with a populated child table based on the selected parent...
0
by: claus | last post by:
Hi, I am not a programmer but tries anyway to program a feature in a form where I am able to copy entries for the form and a subform. I have tried follow the guide here...
7
by: dscarbor | last post by:
I have a simple form with 4 fields, and a subform that retrieves records that are potential matches based on a query. The user will use the ID from the subform record and enter it into one of the...
1
by: garo | last post by:
Hi, Windows MSAccess2003 is not recognizing the subform field that I want to include in my validation. The Main form has an Account# as PrimaryID and a Start Date & End Date. The subform has a...
10
by: maxx429 | last post by:
Good day all, Using Access 2007 but DB is created in Access 200o format so I can still use User Level security. I have what am sure is a very newbie question. I want to add a control to a form...
2
by: ghetto_banjo | last post by:
Ok, i thought i had this one figured out, apparently not. Here is my code on my button click event: stDocName = "frmInvoice" stLinkCriteria = "=" & Me! DoCmd.OpenForm stDocName, , ,...
8
by: Jharp | last post by:
Ok, so im really new to access and programing in general, what i am doing is building a inventory(something simple), the way ive got it set up now is, my entire inventory is in a combo box, and...
4
by: dgunner71 | last post by:
All, I have a Parent form where the Record Source is a query based on three tables (tblcustomers, tblEquipment, and tblWorkOrders). The Parent form has a subform based on a 4th table...
5
by: munkee | last post by:
All, I want to reference a button on the parent form of a subform. The parent however could be two different form names. frmlog frmcorrective How do I check which form is loaded in order...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.