Larry Brister
asked on
MS Access 2003 cannot access Subform making me crazy
This makes no sense to me.
I have 5 forms
Top level form
3 subforms
1 subform on of the first midlevel subform
The following is the structure with the forms names as seen in the MS Access Forms window
ClientVisits
MarketingVisitationClient
MarketingVisitationClientC ontactsWor klist
ClientVisitContactEvent
ClientVisitsNearbyLV
There is a combobox on the top level ClientVisits form.
On the Combobox after update or change event I can access sub routines within all three mid level forms
Example...
Me!MarketingVisitationClie nt.Form.lo adRows
Me!ClientVisitContactEvent .Form.load Questions
But for the LIFE of me I cannot access the sub_sub form named:
MarketingVisitationClientC ontactsWor klist
I can't do it from
ClientVisits
Nor can I do it from
MarketingVisitationClient
Where would be the best place to call the MarketingVisitationClient. Form.routi nename and what syntax on the combobox change or update event?
I have 5 forms
Top level form
3 subforms
1 subform on of the first midlevel subform
The following is the structure with the forms names as seen in the MS Access Forms window
ClientVisits
MarketingVisitationClient
MarketingVisitationClientC
ClientVisitContactEvent
ClientVisitsNearbyLV
There is a combobox on the top level ClientVisits form.
On the Combobox after update or change event I can access sub routines within all three mid level forms
Example...
Me!MarketingVisitationClie
Me!ClientVisitContactEvent
But for the LIFE of me I cannot access the sub_sub form named:
MarketingVisitationClientC
I can't do it from
ClientVisits
Nor can I do it from
MarketingVisitationClient
Where would be the best place to call the MarketingVisitationClient.
You can also use the expression builder (From the main form) to actually "Build" the expression that should get you to the control on the 3rd level form.
For example, I built a three level form and this the path to a control on the 3rd level form, ...from the top level form:
=[frmMid].[Form]![frmBotto m].[Form]! [Text1]
Sample attached
Database72.mdb
For example, I built a three level form and this the path to a control on the 3rd level form, ...from the top level form:
=[frmMid].[Form]![frmBotto
Sample attached
Database72.mdb
ASKER
boag2000
I'm a .Net guys and haven't been in MS Access in a while...rust flakes everywhere.
How do I access the Expression Builder?
I tried using your path above in the VBA to just read a dropped in textbox on my lower form
MsgBox [MarketingVisitationClient ].[Form]![ MarketingV isitationC lientConta ctsWorklis t].[Form]! [txtLarry]
I got this error screen.
I'm a .Net guys and haven't been in MS Access in a while...rust flakes everywhere.
How do I access the Expression Builder?
I tried using your path above in the VBA to just read a dropped in textbox on my lower form
MsgBox [MarketingVisitationClient
I got this error screen.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
?
...Never seen that...?
OK, I don't want to sidetrack the thread too much, ...just try again with the syntax I posted, ...just try to check your spelling carefully (reference the form "Name").
Short of you posting a sample, I am at a loss here.
Please continue on with mbizup to avoid confusion.
Jeff
...Never seen that...?
OK, I don't want to sidetrack the thread too much, ...just try again with the syntax I posted, ...just try to check your spelling carefully (reference the form "Name").
Short of you posting a sample, I am at a loss here.
Please continue on with mbizup to avoid confusion.
Jeff
ASKER
Jeff,
Yeah...I agree. Based on everything I see your example shoud work...hands down.
This isn't super complicated...pretty straight forward. So, I'm going to address your reply, and post a new question for the missing Expression Builder.
Yeah...I agree. Based on everything I see your example shoud work...hands down.
This isn't super complicated...pretty straight forward. So, I'm going to address your reply, and post a new question for the missing Expression Builder.
>> Please continue on with mbizup to avoid confusion.
Hmm... I'm not really sure what else to contribute here. All of your feedback seems to be related to Jeff's suggestions. Did you also see/try mine?
Hmm... I'm not really sure what else to contribute here. All of your feedback seems to be related to Jeff's suggestions. Did you also see/try mine?
ASKER
Did a uninstall and install with everything local and that got me the Expression Builder
<<
Where would be the best place to call the MarketingVisitationClient. Form.routi nename and what syntax on the combobox change or update event?
>>
Curious what was wrong with my suggestion? (you didn't respond to my first comment).
Me!ClientVisitContactEvent .Form.Your SubSubform ControlNam e.Form.You rRoutineNa me
Is the syntactically correct way of calling a routine in a sub-sub form -- assuming that your first level subform control is named "ClientVisitContactEvent".
Where would be the best place to call the MarketingVisitationClient.
>>
Curious what was wrong with my suggestion? (you didn't respond to my first comment).
Me!ClientVisitContactEvent
Is the syntactically correct way of calling a routine in a sub-sub form -- assuming that your first level subform control is named "ClientVisitContactEvent".
ASKER
mbzip
Sorry...I'm buried and should have given you some clarrification on the actual project.
I tried your syntax (and others as well) which is perfectly valid. SHould work...no reason not to. Tried for several days and starting to get curious looks from VP.
So I did the reinstall so I could get the Expression Builder.
Once I had THAT...I could see visually...that I STILL could not get to that form for some reason.
So..
TWO levels up I placed VBA code to unload the subform that is the parent of the one I'm trying to get to
Then I reloaded it.
This flushed the data in the bottom form.
I used this VBA
I then build a user defined table function in SQL Server
On the BOTTOM form I loaded this
So...when I set the parent.parent combobox..
It unloads the (middle) parent
Which flushes the bottom form
reloads the middle form
On expand of the middle form datasheet
The bottom form looks at the Paren.parent and loads the data
Folks...
I'm a .Net guy and didn't build this MS Access App...I inherited it.
I tried literally verything I possible could with every syntax imagineable to access that subform.
It just gave me the happy motorist sign and hid out.
What I have now works...stange as it seems.
Sorry...I'm buried and should have given you some clarrification on the actual project.
I tried your syntax (and others as well) which is perfectly valid. SHould work...no reason not to. Tried for several days and starting to get curious looks from VP.
So I did the reinstall so I could get the Expression Builder.
Once I had THAT...I could see visually...that I STILL could not get to that form for some reason.
So..
TWO levels up I placed VBA code to unload the subform that is the parent of the one I'm trying to get to
Then I reloaded it.
This flushed the data in the bottom form.
I used this VBA
Me!MarketingVisitationClient.SourceObject = ""
Me!MarketingVisitationClient.SourceObject = "MarketingVisitationClient"
Me!MarketingVisitationClient.Form.loadRows
I then build a user defined table function in SQL Server
On the BOTTOM form I loaded this
Private Sub Form_Load()
Dim custid As Long
custid = Me.parent.parent.txtClientID
Dim visitid As Integer
visitid = Nz(Me.parent.parent.cmbVisits, 0)
Dim rcd As ADODB.Recordset
Set rcd = Conn.Execute("SELECT * FROM dbo.udt_VisitClientContacts('" & custid & "','" & visitid & "') ORDER BY ur,AddRemove DESC, Assignment DESC,[Last Name]")
Set Me.Form.Recordset = rcd
End Sub
So...when I set the parent.parent combobox..
It unloads the (middle) parent
Which flushes the bottom form
reloads the middle form
On expand of the middle form datasheet
The bottom form looks at the Paren.parent and loads the data
Folks...
I'm a .Net guy and didn't build this MS Access App...I inherited it.
I tried literally verything I possible could with every syntax imagineable to access that subform.
It just gave me the happy motorist sign and hid out.
What I have now works...stange as it seems.
Thanks for the follow up.
I don't have a copy of Access 2K3 handy, but I seem to recall the expression builder in older versions of Access not going down to the level of detail that it does in A2K7 and 2010.
<< SHould work...no reason not to. >>
Also agree with that...
You were trying to run a function in your sub-sub form, correct? Or just refer to any control on that subform?
IF you were trying to run a sub or function, potential pitfalls are:
1)
<< Private Sub YourCommandButton_Click() >>
Event procedures in forms are by default "Private". To use them from other forms, you need to change that to "Public".
2)
Controls on different forms may have the same name, and so will the default names of their Event procedures. Even though you are using the full path to a sub or function, you may (not sure) need to ensure that the event procedure has a unique name.
___
All that said... I personally (almost) never use this approach. If there is a sub or function that I need to use across multiple forms, I generally will place it in a separate public module. You can pass form and/or control names to public functions as needed.
I don't have a copy of Access 2K3 handy, but I seem to recall the expression builder in older versions of Access not going down to the level of detail that it does in A2K7 and 2010.
<< SHould work...no reason not to. >>
Also agree with that...
You were trying to run a function in your sub-sub form, correct? Or just refer to any control on that subform?
IF you were trying to run a sub or function, potential pitfalls are:
1)
<< Private Sub YourCommandButton_Click() >>
Event procedures in forms are by default "Private". To use them from other forms, you need to change that to "Public".
2)
Controls on different forms may have the same name, and so will the default names of their Event procedures. Even though you are using the full path to a sub or function, you may (not sure) need to ensure that the event procedure has a unique name.
___
All that said... I personally (almost) never use this approach. If there is a sub or function that I need to use across multiple forms, I generally will place it in a separate public module. You can pass form and/or control names to public functions as needed.
ASKER
Thanks...will ask a follow-up new question
Me!ClientVisitContactEvent
Make sure you are using the name of the subform control as seen in your form's deign(which may be different from the name of the subform as seen in the navigation pane)