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!

Subform Issue

Status
Not open for further replies.

mfd777

Programmer
Sep 21, 1999
53
0
0
IE
I am having an issue with implimenting specific security in a database.

The requirement is that when a form loads, a function is called. This function runs through all the controls on the form and sets them to disabled based on information held in a user security table. The calling form passes the form name (me.name) as a parameter. This works fine on its own.

I have two forms A and B. If I open both forms, I have no issue. However if B is a subfom of A, when A opens, the load event of form B (acting as a subform now) crashes because it doesn't recognise the me.name parameter.

Any ideas?
 
sub forms, always load before the main form.

Can you run the subform code, from the main form, by making it public, or by changing the reference syntax, slightly?

Me.subformName.Form.ControlName

Hope this helps, good luck!
 
Thanks for your suggestion Zion7. To keep the function applicable to all forms, I need to programatically determine if a form is loading as a subform or a main form. Are you aware of a property on the form that I could read?
 
mfd777, off hand, I don't know how to determine, whether a form is loaded as a subform or not, besides checking the "LinkChildFields" property. as a subform, it will have this property, main form no.

But maybe as a workaround. since your argument I assume, will always be the same record from the main form (1st one it opens on), can't you open a recordset to get that value?

So if the main forms recordsource is ....
SELECT * FROM .... WHERE ..... ORDER BY....

using the same statement, a recordset will always open the same way as the form. So you can always get your desired value regardless?

so now you would pass "rec!Name", as your argument.

Hope this helps, good luck!
 
Take a look at the Parent property:
On Error Resume Next
If IsObject(Me.Parent) Then MsgBox TypeName(Me.Parent)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top