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

Populating subform

P: 19
hi ,

I created a database using Access 2000 with 2 tables and 2 forms. one is main form and the other subform with ID and Name as common fields. I have a command button in main form which is used to open the subform. Now my question is whenever I enter ID or Name in the main form and then click on the subform it should give me the whole record in the subform which is related to the ID or Name in the main form. I am able to open the form with the ID but each time if i enter a ID the subform opens with the ID but the details in the subform remain the same as of the previous record, it is not giving the current record for the ID entered. I am stuck at this point and unable to complete my project which is due for monday.If anyone can help me out this would be grateful.I am new to access eenvironment.
Nov 30 '06 #1
Share this Question
Share on Google+
9 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
hi ,

I created a database using Access 2000 with 2 tables and 2 forms. one is main form and the other subform with ID and Name as common fields. I have a command button in main form which is used to open the subform. Now my question is whenever I enter ID or Name in the main form and then click on the subform it should give me the whole record in the subform which is related to the ID or Name in the main form. I am able to open the form with the ID but each time if i enter a ID the subform opens with the ID but the details in the subform remain the same as of the previous record, it is not giving the current record for the ID entered. I am stuck at this point and unable to complete my project which is due for monday.If anyone can help me out this would be grateful.I am new to access eenvironment.
Subforms are generally only bound to the main form with one field e.g. ID. If you want to use both fields then you can only set it where both fields are matched unless you use filters which is complicated.

If you want to set it for both fields then you need to check the properties of the subform object (the frame). Under the data tab there are two properties called 'Link Child Fields' and 'Link Master Fields'. Both fields should be represented as follows:

[ID];[Name]
Dec 1 '06 #2

P: 19
thank you for the reply. as you said i will just go with one field so that it can populate the related fields in subform.

And also i don't find any linkchildfield and linkparentfield in my subform as i hv created the form through wizard and attached it to the command button onclick() event. i just wanted to know how we write the code in order to call the details for subform with the main form ID field.
Dec 2 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
thank you for the reply. as you said i will just go with one field so that it can populate the related fields in subform.

And also i don't find any linkchildfield and linkparentfield in my subform as i hv created the form through wizard and attached it to the command button onclick() event. i just wanted to know how we write the code in order to call the details for subform with the main form ID field.
The properties aren't on the subform they're on the subfom object. In main form design view click on the frame around the subform and open properties. You'll find them under the data tab.

Mary
Dec 2 '06 #4

P: 19
I understand what you are saying but as I said I have created the subform using the icon "create a form through wizard". I haven't created using the subform wizard. So, now what do you suggest me for this?
Dec 2 '06 #5

P: 19
Hey I am sorry I was bit confused between the forms. As I mentioned it is a main form and subform I was wrong in that. Actually my database contains a form in which I have command button by clicking on it a pop up form opens up..so, i wanted the details to be populated in the pop up form with the field ID on the main form.
Dec 2 '06 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
Hey I am sorry I was bit confused between the forms. As I mentioned it is a main form and subform I was wrong in that. Actually my database contains a form in which I have command button by clicking on it a pop up form opens up..so, i wanted the details to be populated in the pop up form with the field ID on the main form.
You need to set criteria on the open form command.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub ButtonName_Click()
  3. Dim stDocName As String
  4. Dim stLinkCriteria As String
  5.  
  6.    stDocName = "PopupFormName"
  7.    stLinkCriteria = "[ID]=" & Me.ID
  8.  
  9.    DoCmd.OpenForm stDocName, , , stLinkCriteria
  10.  
  11. End Sub
  12.  
Dec 2 '06 #7

P: 19
I have tried as you said but when the pop up form opens it just opens with the Id ,it does not give the details on the pop up form related to that Id. Wht I should do for this?
Dec 4 '06 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
I have tried as you said but when the pop up form opens it just opens with the Id ,it does not give the details on the pop up form related to that Id. Wht I should do for this?
Your popup form must be bound to the table or query to populate the data. All the criteria does is tell it which record to open.
Dec 4 '06 #9

P: 19
Thank you so much for helping me out. I never thought that this will be very simple.

Once again thank you so much...........
Dec 4 '06 #10

Post your reply

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