Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

If your subform name is TabelaMeta_subform, the form class module is Form_TabelMeta_Subform. So the call to run procuedre in your subform is:

Call Form_TabelMeta_Subform.EnableControls

In general: If you want to call a Public procedure in any of your forms, you must prefix the form name with "Form_" to refer to the class module of that form.

But when referring to the name of the subform, it is without the "Form_".

But in this case, when you're referring to the name of a subform control, it is the name of the control on the main form that you're checking, not the name of the form itself. If you want to refer to the name of the subform that is used by the control, you have to do someting like:

   If TypeOf ctl is SubForm then
      If ctl.SourceObject = "TabelaMeta_Subform" then
         Call Form_TabelaMeta_Subform.EnableControls

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 28th, 2005, 09:24 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much !
I'll try.
rgds P.



 
Old March 28th, 2005, 02:55 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem now seems to be:
When the subform code reads .Locked = No, .Enabled = Yes, the subform is
overunned by the Main form properties settled as .Locked = Yes, .Enabled = No.
I would like to let only the subform as prompt to enter data.
Would it be possible?
rgds P.

 
Old March 30th, 2005, 11:08 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Are you setting the .Locked and .Enabled properties of the subform object on the main form? The subform object will have to be unlocked and enabled too.

I'm not clear about your question "I would like to let only the subform as prompt to enter data." It sounds like you're saying that you don't want the user to be able to do any data entry on the main form.

I think the path you're traveling is that you want the main form to lookup information and the subform to allow editing specific parts of that information. If that is the case, probably the best way to do that is to not bind the main form to a record source. Provide a dropdown to select a record (e.g. Person's name). Have one subform to display the data for the person. This form will have "Allow Edits", "Allow Deletions" and "Allow Additions" set to false. The other subform will be the one where you are unlocking and enabling.

Perhaps a little more description of exactly what you're tyring to accomplish is in order.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old March 30th, 2005, 01:34 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ur description above is exactly what i would like to do. Although as i was
not familiar with coding the subform independently of the main form, because
it seemed that the subform was ruled by the main form proprieties, i've
solved the question linking a form to a main form. The linked form has the
fields of the ulterior subform and the code above works OK. So i'll let
the problem above to a further thinking.
Thanks very much for ur support.
rgds P.

 
Old April 2nd, 2005, 09:30 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Back again !
The way i thought would do the task did not work. Because when trying to enter
data on the linked form a message shows pointing to the inconvenience of
having the form linked to the main form. What i want to do ? Here it goes:
have employees as main form and informations about employees on the subform.
Those informations are supplied every month so each salary can be calculated.
Using an unbound combo box to provide the employees names , as Randall has suggested, would the informations be related to each employee ?
rgds Penta.

 
Old April 2nd, 2005, 04:29 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

The information in the subform is dependent on the Master and Child link fields.

To answer your question... If you have a combo box to select the employee by name, you most likely have the Bound Column property of that combo box set such that it points to the Employee's ID field. If your subforms indicate that the Master link field is the combo box and the Child field is the Employee ID field of the Record Source for that form, then the subform will display data only for the employee selected in that combo box.

I am certain that Access does not provide a message about "pointing to the inconvenience" of anything. Without knowing what you did or what the real message is, I am lost as to how to help.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old April 4th, 2005, 06:02 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry to not have the "ipses literis" message (the real words of MsAccess message) by memory. Although the meaning of the message was : cant entry data
because the form have a relationship with some other form. I'll try again
and again, before i post my missknowledge to u.
Thanks u all.
rgds P.

 
Old April 4th, 2005, 08:17 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey penta, I wasn't berating you for the lack of precise message. I was just saying it's difficult to help.

I have not run into a situation where I couldn't enter data that will be stored in a database on a form because of a relationship with some other form and where I've received a message.

However, I have had a message that said I couldn't use the Master/Child Link field builder (the elipses "..." to the right of the Master/Child Link Field Properties of a subform) because the parent was not a bound form. That could be what you meant by "entering data". I believe in this case it would have been more correct to say "I can't set the properties for the Master/Child Link Fields".

If that is what is happening, the message is "Can't build a link between unbound forms". If that had been the message you reported, I could have interpreted your "entering data" to mean that you couldn't set the Master/Child Link Field properties. Then I could have told you that you can't use the builder to select the linked fields. But you can enter the link fields without using the builder. So you see, since you didn't quote the exact message, I'm just guessing.

As far as not being able to enter data to the database, I don't recall when I've ever had a message that said I couldn't enter data because of the relationship between forms. One case where I couldn't enter data on a form has been because the query I used as the Record Source for a form was not an updatable query. But no message was reported for this situation.

Another situation might be because of a relationship in the database. For example, two tables that are linked where referential integrity is enforced. But this problem is not really because of the link between forms. So I don't think the message would have indicated anything about forms. Although it might have. But there again, without the message quoted, I have trouble deciphering your situation and figuring out how to help.

At any rate, no offense was meant. So I'm sorry if you felt that. But an exact quote of the message can help us provide you more help.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old April 4th, 2005, 09:07 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No offense at all! I'm sorry for my bad English ! Here goes the problem:
Main form : Employees; Linked form : Informations about employees. Referencial
integrity enforced. When i try to enter data to the Linked form the following
message is displayed:"You cannot add or change a record because a related
record is required in table 'Employee'."
Thanks Randall!
P.





Similar Threads
Thread Thread Starter Forum Replies Last Post
General Naming(reaching) buttons kekec3778 Beginning VB 6 3 January 8th, 2008 05:05 PM
My Comments on reaching the end of the book Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 August 5th, 2006 07:26 AM
Problem putting code on the right event - SubForm mmcdonal Access VBA 0 November 24th, 2004 01:55 PM
Urgent!! code for no match in Subform based query smercer Access 3 September 10th, 2004 11:15 PM
Filter Subform B Based on Field in Subform A SerranoG Access VBA 3 June 18th, 2004 12:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.