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

Pass value to form and embedded subforms.

Status
Not open for further replies.

MkIIISupra

Programmer
Apr 17, 2002
108
US
Hey all, been a while since I have been here. Anyhow, I have a main form that can be fed from one of two data sources. Within that form are three subform, each of which also have two possible datasources.

I am trying to get the main form AND the sub forms to open and based on a value passed, select the appropriate data source. Now the main form is getting the appropriate command and opening the appropriate data source when called. But the sub forms are not. Below is my code and an error that I am getting. I have been looking and have not found the answer to my specific question... yet.

CODE BLOCK
Private Sub Form_Load()

DoCmd.Maximize

If (Me.OpenArgs) = "New" Then
' Use the Quert Select Customer to load the main form, then each SUB form is to be _
& assigned to it's appropriate Select query.
Me.Form.RecordSource = "qrySELECT_ShowCustomer"
Me.Requery

' These are the subForms I need to associate with the appropriate datasource.
Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource = "qrySELECT_ShowShipper"
Me.subTransportationInformation!frmSELECT_ShowTransport.RecordSource = "qrySELECT_ShowTransport"
Me.subProductInformation!frmSELECT_ShowProduct.RecordSource = "qrySELECT_ShowProduct"
' MsgBox Me.OpenArgs
Exit Sub

ElseIf (Me.OpenArgs) = "Old" Then
' Use the Quert Recall Customer to load the main form, then each SUB form is to be _
& assigned to it's appropriate recall query.
Me.Form.RecordSource = "qryRECALL_Customer"
Me.Requery

' These are the subForms I need to associate with the appropriate datasource.
Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource = "qryRECALL_Shipper"
Me.subTransportationInformation!frmSELECT_ShowTransport.RecordSource = "qryRECALL_Transport"
Me.subProductInformation!frmSELECT_ShowProduct.RecordSource = "qryRECALL_Product"
' MsgBox Me.OpenArgs
Exit Sub

End If

End Sub

ERROR MESSAGE
Run-time error '2465':

Microsoft Access can't find the field 'frmSELECT_ShowShipper' referred to in your expression.


SYSTEM SPECS
OS = Windows 2000 Pro running inside of Ubuntu Linux via VMWare.
Office Version = Access 2000 Professional

I hope this is enough to garner some assistance. I am continuing my search for the answer but as of late, no luck. I have also tried declaring my subforms as variables to no avail as well, unless I am declaring them wrong.

One by one the penguins steal my sanity!
 
How are ya MkIIISupra . . . . .

To make this eaiser, whats the [blue]name of the mainform & subforms[/blue] (hard to pick out whats happening here)?

Calvin.gif
See Ya! . . . . . .
 
CODE BLOCK
Private Sub Form_Load()

DoCmd.Maximize

If (Me.OpenArgs) = "New" Then
' Use the Quert Select Customer to load the main form, then each SUB form is to be _
& assigned to it's appropriate Select query.


-- This is referencing the Main Form --> Me.Form.RecordSource = "qrySELECT_ShowCustomer"
Me.Requery

' These are the subForms I need to associate with the appropriate datasource.
Any thing that has Me.sub is a subform reference
Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource = "qrySELECT_ShowShipper"
Me.subTransportationInformation!frmSELECT_ShowTransport.RecordSource = "qrySELECT_ShowTransport"
Me.subProductInformation!frmSELECT_ShowProduct.RecordSource = "qrySELECT_ShowProduct"
' MsgBox Me.OpenArgs
Exit Sub

ElseIf (Me.OpenArgs) = "Old" Then
' Use the Quert Recall Customer to load the main form, then each SUB form is to be _
& assigned to it's appropriate recall query.

Me.Form.RecordSource = "qryRECALL_Customer"
Me.Requery

' These are the subForms I need to associate with the appropriate datasource.
Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource = "qryRECALL_Shipper"
Me.subTransportationInformation!frmSELECT_ShowTransport.RecordSource = "qryRECALL_Transport"
Me.subProductInformation!frmSELECT_ShowProduct.RecordSource = "qryRECALL_Product"
' MsgBox Me.OpenArgs
Exit Sub

End If

End Sub


So the three sub forms above are:

1. Me.subProductInformation!frmSELECT_ShowProduct
2. Me.subShippersInformation!frmSELECT_ShowShipper
3. Me.subTransportationInformation!frmSELECT_ShowTransport

One of the sub forms is Me.subProductInformation then form that is embedded within is frmSELECT_ShowProduct.

Does that help?

One by one the penguins steal my sanity!
 
MkIIISupra . . . . .

I'll try to attack this another way . . . form referencing is whats misleading here! For instance . . . [blue]Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource[/blue] saids you have:
[ol][li] [blue]MainForm[/blue] [blue]with subForm[/blue] subShippersInformation. Is this correct?[/li]
[/li] [blue]subForm[/blue] subShippersInformation [blue]with subForm[/blue] frmSELECT_ShowShipper. Is this correct?[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Sorry about the mess . . . should be :

I'll try to attack this another way . . . form referencing is whats misleading here and your apparent problem! For instance . . . [purple]Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource[/purple] saids you have:
[ol][li][blue]MainForm with subForm[/blue] subShippersInformation. Is this correct?[/li]
[li][blue]subForm[/blue] subShippersInformation [blue]with subForm[/blue] frmSELECT_ShowShipper. Is this correct?[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Code:
[COLOR=#000000][s] Me.Form.RecordSource = "qrySELECT_ShowCustomer"
[/s][/color]
Code:
[COLOR=#000000] Me.RecordSource = "qrySELECT_ShowCustomer"
[/color]
==============================================
Code:
[COLOR=#000000][s]Me.subShippersInformation!frmSELECT_ShowShipper.RecordSource = "qrySELECT_ShowShipper"
[/s][/color]
Code:
[COLOR=#000000]Me.YourSubFormName.Form.RecordSource = "TableOrQueryName"
[/color]

like wise...


________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
My guess:
Me!subShippersInformation.Form.RecordSource = "qrySELECT_ShowShipper"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks! Your help has again gotten me past another silly issue!

One by one the penguins steal my sanity!
 
Can you tell us which answer was correct? Just to know..

________________________________________________________________________
Zameer Abdulla
Visit Me
Children are poor men's riches.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top