By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

controlling a subform from main form?

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
"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

P: n/a
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

P: n/a

"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.