473,624 Members | 2,453 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 frmretailorderl ine.

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 <> "changestat us" 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 <> "changestat us" 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 2551
"Craig M" <No**@mPlz.Th x> wrote in message
news:40******** *************** @news-text.dial.pipex .com...
Hi,

I have 2 forms, frmretailorders , and frmretailorderl ine.

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 <> "changestat us" 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 <> "changestat us" 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 frmretailorderl ine.

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 <> "changestat us" 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 <> "changestat us" 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
frmretailorderl ine in the mainform then

Me.frmretailord erline.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.co m> wrote in message
news:oe******** *********@newsr ead1.news.pas.e arthlink.net...
Craig M wrote:
Hi,

I have 2 forms, frmretailorders , and frmretailorderl ine.

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 <> "changestat us" 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 <> "changestat us" 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
frmretailorderl ine in the mainform then

Me.frmretailord erline.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.co m> wrote in message
news:oe******** *********@newsr ead1.news.pas.e arthlink.net...
Craig M wrote:
Hi,

I have 2 forms, frmretailorders , and frmretailorderl ine.

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 <> "changestat us" 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 <> "changestat us" 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
frmretailorde rline in the mainform then

Me.frmretailo rderline.Enable d = (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 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:
25
10212
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 data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
12
19004
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, frmBrowseNegsSubform. I would like to perform an ascending or descending sort on any of the 7 columns shown in datasheet view in the subform control. I've been unsuccessful. Is there something tricky about sorting in subform controls?
4
7001
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 user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
9
2737
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 selected in the main form. I thought all I had to do for the subform was create a query and set the criteria equal to the option group value in the main form. No way, Jose! When the form/subform opens, the option group value is not available to the...
10
2964
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 http://allenbrowne.com/ser-56.html and it works great, but I need to unlock and lock my main form and subform separately, using two different buttons.
9
9681
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 master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
6
5964
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 forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public Function akeyEdit()
8
18216
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 orientated form. Both forms contain records of 'shifts' I want to be able to select a record (a shift) in the subform, and be able to set the parent form's current record to that record, through the identifying primary key that a shift record has...
4
8825
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 which allows me to edit the record in the subform. What I want to happen is for subform with the new edits to be updated on the main form when I close the popup. I'm sure this is a very small bit of code in the the 'On close' event for the popup...
0
8175
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
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 we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.