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

Freezing Forms

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi...

I know I kinda asked this question last week but...

I am trying to create a form with two subforms on it.

All forms have checkboxes. I want to be able to
freeze 2 of the forms if one out of the three forms
checkboxes is selected.

ie...

Form one

{}Shoes If I select any of these boxes
{}Feet Do not let me select from Subform 1 or Subform 2.
{}Hands

Subform 1

{}Mittens If I select any of these boxes
{}Gloves Do not let me select from Form 1 or Subform 2.
{}Hats

Subform 2

{}Pants If I select from any of these boxes
{}Shorts Do not let me select from Form 1 or Subform 1.
{}Shirts

I hope you can help.

Thanks

Greg Rodgers
 
Hello Greg,

I am at work and can't test this but I think this would work. Make all three of them subforms and assume that the subform controls on the main form are named SubForm1, SubForm2 and SubForm3.

In the On Dirty event of each of the subforms, put code to disable the other 2. For example, in SubForm1's On Dirty event, put SubForm2.locked = true, SubForm3.locked = true, etc.

Or, if you are comfortable spinning the Access collections, you could do something like the following:

Dim ctl As Control

Which ever property returns type of control and whatever
value indicates a subform

For each ctl in form.controls
if ctl.type = 4 then
if ctl.name <> me.name then
ctl.enabled = false
ctl.locked = true
end if
end if
Next ctl

Then you would want to reverse the above in the on current events for your form, either main or subform.

Let me know how this works and good luck!
 
Thanks, but...

I'm sorry...&quot;On Dirty&quot;..what is that?

&quot;assume that the subform controls on the main form are named...&quot; If I put three subforms on a form then where
would I put the control names on the form?

Thanks

Greg Rodgers
 
Greg,

I'll try to answer more fully when I get home. A subform is just another control. If you select the subform area and then click on properties, the name of the control is on the other tab.

Good Luck!
 
Hello Greg,

I created an example using 3 subforms called Hats, Coats and Shoes. If you post an email address, I will send it to you. In the mean time, below is an attempted explanation about what is going on. Others may feel free to clarify and elaborate.

If you create a stand alone form, it will become a subform by dragging it onto another form. I'm not trying to insult you here, these are things that I really had a hard time with when I first started to use subforms.

If you open up the subform in stand alone mode, then one of the form event properties is OnDirty. This event is raised whenever there is a change made to one of the controls on the form.

When you drag a form on to another form, the subform form is contained in a subform control on the main form. If you click on the properties button for the subform container on the main form and then select the data tab you will see that the Source Object is the name of your stand alone form before you drug it onto the main form.

If you click on the other tab, you will see name as a property. Here is where you would name the Main form Subform container SubForm1, SubForm2, etc.

People get confused between the subform control on the main form which is just a container to hold the actual subform and the actual subform which is the form you created for that purpose.

The form you created to be used as the subform still retains its event code logic. That's why you can put code in the IsDirty event to disable the subforms. If you disable or lock the container which holds the subform, by definition you have disabled or locked the form which makes up the subform. I hope this helps a little bit.

If you post an email address, I will send you an example so you can see what I am talking about.

Good Luck!
 
Hey...

Thanks for the tip!

My e-mail address is bombreals@hotmail.com

Please send it to me and thanks a lot!

GR
 
Also...

Could you please elaborate on &quot;If you create a stand alone form, it will become a subform by clicking and dragging it on to another form.&quot;

I have already created a form with three subforms that are
titled. I've clicked on each subform and I still do not see
the OnDirty event.

Please point me in the right direction.

Thanks

GR
 
SendBuckeye
Sent you an e-mail back...you may want to check it...

I'm sorry. I read your e-mail. I still do not see an event
property called &quot;OnDirty&quot;. I have no idea how to access it or how to make it appear. I see OnUpdate,OnClick,BeforeUpdate..no OnDirty. Is this an event
on Access 2000? I am using 97.

Is there an easier way to get to it? Anyone else care to chime in...thanks for putting up with me on this query!

GR
 
Greg,

Sorry, that is an Access2000 feature. Use the Form After Update event instead. It should give you the same type of functionality. One of the forms in the example uses that instead of OnDirty. I will try to get you a copy in Access97. Sorry, I didn't think to ask which version you were using.
 
Thats works...now only one problem.

If after the subform I check is not the one I need,
after de-selecting the check box I'd like the lock on the
other forms to be lifted.

What do I do to have that happen?

Thanks for your help.

GR
 
Lastly..hehe!

Once the forms are frozen, is there a way to turn the checkboxes on the frozen forms grey?

GR
 
If you disable them without locking them they will turn gray (eg enabled = false, locked = false).

Not sure about your prior question. How many check boxes do you have on each subform? Is that all you have on each subform? So, if any one or many checkboxes are checked then you want the other subforms to be locked. If all of the check boxes on the selected subform are cleared, then you want the other subforms re-enabled? Do I understand you correctly?

 
It sounds like maybe you have a checkbox on each subform that indicates that you want to process from that one and lock the others. Then, if you clear it you want to allow the others to now be selected.

If I have understood you correctly, then in the afterupdate code for the checkbox put something like the following (very similar to the Form Current event logic):

If chkSubForm1 then
disable the others like you are currently
Else
enable the others similarly to Form Current
End If

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top