473,499 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

controlling a subform from main form?

Hi,

I have 2 forms, frmretailorders, and frmretailorderline.

in the oncurrent of the main form, I check what the value of !status is. If
it is "complete", then i disable all text and combo boxes. However, I also
want to disable all of the same on the sub form. I do not know how to
reference the sub form :s

Current code:
----------------------------------------------
dim obj As Control

If status = 2 Or 3 Then
For Each obj In Me.Controls
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next
For Each obj In <REFER TO SUB FORM HERE>
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next

End If

End Sub
----------------------------------------------

The first IF works, but i need to get the second one working :)

if you can help, thanks in advance.

Craig
Nov 12 '05 #1
4 2532
"Craig M" <No**@mPlz.Thx> wrote in message
news:40***********************@news-text.dial.pipex.com...
Hi,

I have 2 forms, frmretailorders, and frmretailorderline.

in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo boxes. However, I also
want to disable all of the same on the sub form. I do not know how to
reference the sub form :s

Current code:
----------------------------------------------
dim obj As Control

If status = 2 Or 3 Then
For Each obj In Me.Controls
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next
For Each obj In <REFER TO SUB FORM HERE>
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next

End If

End Sub
----------------------------------------------

The first IF works, but i need to get the second one working :)

if you can help, thanks in advance.

Craig


Well, I managed to access the subform, but now, when I try and run it, the
loop hits the subform and says "You cannot disable a control while it has
the focus".

How can i work around this?

Craig
Nov 12 '05 #2
Craig M wrote:
Hi,

I have 2 forms, frmretailorders, and frmretailorderline.

in the oncurrent of the main form, I check what the value of !status is. If
it is "complete", then i disable all text and combo boxes. However, I also
want to disable all of the same on the sub form. I do not know how to
reference the sub form :s

Current code:
----------------------------------------------
dim obj As Control

If status = 2 Or 3 Then
For Each obj In Me.Controls
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next
For Each obj In <REFER TO SUB FORM HERE>
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next

End If

End Sub
----------------------------------------------

The first IF works, but i need to get the second one working :)

if you can help, thanks in advance.

Craig

Why don't you simly disable the subform instead of disabling all the
controls in the subform? Assuming your subform name is
frmretailorderline in the mainform then

Me.frmretailorderline.Enabled = (Me.status <> 2 And Me.Status <> 3)

will disaable if the status is not 2 or 3.

You can also lock the fields instead of disabling. If you lock
something you have to be aware that tho data can't be changed, if you
have an OnClick or OnDblClick event set that can fire.

Nov 12 '05 #3

"Salad" <oi*@vinegar.com> wrote in message
news:oe*****************@newsread1.news.pas.earthl ink.net...
Craig M wrote:
Hi,

I have 2 forms, frmretailorders, and frmretailorderline.

in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo boxes. However, I also want to disable all of the same on the sub form. I do not know how to
reference the sub form :s

Current code:
----------------------------------------------
dim obj As Control

If status = 2 Or 3 Then
For Each obj In Me.Controls
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next
For Each obj In <REFER TO SUB FORM HERE>
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next

End If

End Sub
----------------------------------------------

The first IF works, but i need to get the second one working :)

if you can help, thanks in advance.

Craig

Why don't you simly disable the subform instead of disabling all the
controls in the subform? Assuming your subform name is
frmretailorderline in the mainform then

Me.frmretailorderline.Enabled = (Me.status <> 2 And Me.Status <> 3)

will disaable if the status is not 2 or 3.

You can also lock the fields instead of disabling. If you lock
something you have to be aware that tho data can't be changed, if you
have an OnClick or OnDblClick event set that can fire.


Ahh, great!

I ended up locking all of the fields, and changing the BG color, heh.

Thanks for the info, I will try it in a few.

Craig
Nov 12 '05 #4
Craig M wrote:
"Salad" <oi*@vinegar.com> wrote in message
news:oe*****************@newsread1.news.pas.earthl ink.net...
Craig M wrote:
Hi,

I have 2 forms, frmretailorders, and frmretailorderline.

in the oncurrent of the main form, I check what the value of !status is.
If
it is "complete", then i disable all text and combo boxes. However, I
also
want to disable all of the same on the sub form. I do not know how to
reference the sub form :s

Current code:
----------------------------------------------
dim obj As Control

If status = 2 Or 3 Then
For Each obj In Me.Controls
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next
For Each obj In <REFER TO SUB FORM HERE>
If obj.ControlType = acTextBox Or obj.ControlType = acComboBox And
obj.Name <> "changestatus" Then
obj.Enabled = False
End If
Next

End If

End Sub
----------------------------------------------

The first IF works, but i need to get the second one working :)

if you can help, thanks in advance.

Craig


Why don't you simly disable the subform instead of disabling all the
controls in the subform? Assuming your subform name is
frmretailorderline in the mainform then

Me.frmretailorderline.Enabled = (Me.status <> 2 And Me.Status <> 3)

will disaable if the status is not 2 or 3.

You can also lock the fields instead of disabling. If you lock
something you have to be aware that tho data can't be changed, if you
have an OnClick or OnDblClick event set that can fire.

Ahh, great!

I ended up locking all of the fields, and changing the BG color, heh.

Thanks for the info, I will try it in a few.

Craig

Try this.

Create a temp form and drag a few text boxes on the form. Set the following

Enable Locked
True False
True True
False True
False False

Then open the form. The background changes depending on the enable/lock
status.

You could do something like this
blnEnable = True
Me.Text0.Enable = blnEnable
Me.Text0.Locked = Not blnEnable

So if you did want to cycle through a control list you can come up with
an effect that suits you and the users.

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
673
by: Craig M | last post by:
Hi, I have 2 forms, frmretailorders, and frmretailorderline. in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo...
25
10162
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
12
18977
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
4
6965
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
9
2729
by: PC Datasheet | last post by:
I'm stuck on something that seems should be easy and I need some help. My main form has an option group with five options. My subform chooses from different lists depending on which option is...
10
2946
by: Ami | last post by:
Hello everyone, I have developed a small access application and now I need to lock my forms against unwanted edits. I have used the code by Allen Browne I found here...
9
9665
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
6
5930
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
8
18205
by: anansi | last post by:
Hi I have a form called 'shiftviewer' and it contains a subform called 'all shifts for current month subform'. the subform is in datasheet view (access 2007) and the main form is a column...
4
8800
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.