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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form with tabbed pages for subforms 1

Status
Not open for further replies.

Dophia

Technical User
Jul 26, 2004
263
0
0
CA
Hello Everyone: I have a main form with many subforms placed on tabbed pages, all linked to the main form. I would like to change some the subforms to be opened by a button instead. But the problem is that some of the subforms have not yet been populated, so I will need to pass the main form's primary key to the subform that opens. Just so the user does not have to enter it again.

Code:
Private Sub BtnPound_Release_Click()


DoCmd.OpenForm "SubformCatDetailsPoundRelease", WhereCondition:="[Pound_Sheet_No]=" & Me![Pound_Sheet_No], WindowMode:=acDialog, OpenArgs:=Me.Pound_Sheet_No

End Sub

I get an error, Enter Paramater value "zb". That [Pound_Sheet_No] is 1000-zb. So, I don't understand how to fix this.

If there is an easier way to change a linked subform to a button, please let me know.

Thank you, Sophia




 
Apparently the Pound_Sheet_No field is text. Try
Code:
Private Sub BtnPound_Release_Click()

DoCmd.OpenForm "SubformCatDetailsPoundRelease", WhereCondition:="[Pound_Sheet_No]=[highlight #FCE94F]'[/highlight]" & Me![Pound_Sheet_No] [highlight #FCE94F]& "'"[/highlight], WindowMode:=acDialog, OpenArgs:=Me.Pound_Sheet_No

End Sub

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thank you Duane. That was the issue for the error. But now when the subform opens and I fill in the data, the [Pound_Sheet_No] does not transfer to the subform automatically. I thought that that code would do it?

Sophia
 
You would need to set the default value of the linking/child field to the contents based on the value of OpenArgs.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks again Duane. It is working now.

Is there an easier way to have a button open a linked subform? It is so easy to have subform linked to a main form the traditional way by having both forms on screen.

Sophia
 
I'm not sure why you want to open a new form when a subform can be used.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
I want to open a form with a button, to save space on the main form. There are too many subforms showing in the Page Tabs across the screen, with the subforms on the page tabs.
I am just trying to make it visually better to look at.

Sophia
 
You have a process now with openargs and setting the default value. There are methods for hiding subforms until needed. I expect your app might not show more than 2-3 subforms at any point.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks for the advise. :)

Sophia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top