Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate field in new record added on subform with data from main form

Status
Not open for further replies.

jcfraun

Technical User
Dec 13, 2008
51
US
I have a form (f_Pages_Update - based on the table t_Pages_Update) and a subform (f_Keywords_Update - based on the table t_Keywords_Update).

The form has the following fields:
Page
Priority
Level
URL

The subform has the following fields:
Page
Keyword
MonthlySearches
Ranking
Status (Add, Remove, Keep)

For each page, the associated keywords appear in the subform. That part is working fine.

The problem I'm having is when I want to add a new associated keyword to the subform. It gives me an error message: "Visual Basic can't convert the data type of one of the arguments you entered." If I say ok, then I can still enter the new keyword with no more error messages. I would like to know how to prevent this error message.

Also, when I look at the table t_Keywords_Update, I would like that new record to have the Page field populated with the parent Page from the main form. Right now it's blank. Does that make sense?
 
Sounds to me that you did not link your subform control to your main form. Instead you tried to code the behavior of the subform and did it incorrectly. Just use the native subform linking and you should be fine.

1)Provide the sql for the subform and main form
2)Provide the following properties of the subform control
LinkMasterFields:
LinkChildFields
3)Provide any code in the mainform or subform that you use to filter records in the subform to records in the main form.
 
Maybe I should start over, because for some reason, I am just not able to find the Master/Child fields. I created my forms using the form wizard and they were working correctly, but adding data to the subform was creating problems (i.e., blank Page field).

So, starting over: I have two tables.

Table 1:
t_RosettaPages_Update with fields:
Priority
Page
Level
URL

Table 2:
t_RosettaKeywords_Update with fields:
ID
Page
Keyword
Monthly Search
Ranking
Status


There is a one to many relationship between the tables:
Table1.Page (one) - Table2.Page (many)

What I want is to look at these by page with all associated keywords. And I want to be able to add keywords to Table2, but the thing is that I need the page added to that table also.
 
How are ya jcfraun . . .
jcfraunMast said:
[blue] ... I am just not able to find the Master/Child fields.[/blue]
[ol][li]Open [blue]f_Pages_Update[/blue] in design view.[/li]
[li]Open the [blue]properties window[/blue] and select the [blue]data tab[/blue].[/li]
[li]Now ... carefully select the outline of the subform. The [blue]Master/Child[/blue] properties should now show!.[/li][/ol]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceMan1 - Thanks. I see that now!

Dhookom - I am not adding anything to the master/page record --- only to the subform using an existing page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top