473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Not allowing edit in a main form disabling edits in a subform

222 100+
Dear Friend


Working on access 2007 sp2.

My form is consisting from a form and a subform.

while i am using the alowedits=no option on the property of the main form it is preventing me to edit my subform.

Is there any method where I will be able to stop edit in the main form while the subform still editable ?

I don't want to go through VBA because I do have many attributes and action on this forms...

Thank you in advance

Regards
Oct 27 '09 #1

✓ answered by missinglinq

You'll need to loop thru the controls on the main form, and if the control type is not subform, lock it.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim ctrl As Control
  3.  
  4. For Each ctrl In Me.Controls
  5.  If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox) Then
  6.    ctrl.Locked = True
  7.  End If
  8. Next
  9.  
  10. End Sub
This locks textboxes and comboboxes, if you have other controls on the main form that need locking, you simply add them to the

If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox)

line in a like manner.

Linq ;0)>

8 10281
NeoPa
32,556 Expert Mod 16PB
Wassim, Your question seems to be the opposite of the title. What is it you're asking about exactly?
Oct 27 '09 #2
wassimdaccache
222 100+
Sorry About the subject I was trying to say
while I disable edit in the main form, access is disabling edits in the subform too

the question is:

Is there any method where I will be able to stop edit in the main form while the subform still editable ?

Thank you
Oct 27 '09 #3
missinglinq
3,532 Expert 2GB
You'll need to loop thru the controls on the main form, and if the control type is not subform, lock it.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim ctrl As Control
  3.  
  4. For Each ctrl In Me.Controls
  5.  If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox) Then
  6.    ctrl.Locked = True
  7.  End If
  8. Next
  9.  
  10. End Sub
This locks textboxes and comboboxes, if you have other controls on the main form that need locking, you simply add them to the

If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox)

line in a like manner.

Linq ;0)>
Oct 27 '09 #4
Megalog
378 Expert 256MB
Go to the subform's form properties, and be sure the Allow Edits is set to YES.
I just tested this on a new form/subform and it worked fine with the main form locked down, but I had to then change the subform's property back to allow edits there.

If you are locking down the main form with VBA, then basically follow that statement with another line to ENABLE the edits for the subform. It may be that access is automatically propogating that property from the main form, to the subform?
Oct 27 '09 #5
missinglinq
3,532 Expert 2GB
If AllowEdits is set to No on the main form, then no control on the main form can be editied, including the subform control! That's why the only way to handle this is as I've suggested. You have to lock all controls on the main form except the subform control.

Linq ;0)>
Oct 27 '09 #6
Megalog
378 Expert 256MB
I stand corrected, Linq is right as usual ;)

I could've sworn I had it working in a test db.. then I created one from scratch and couldnt get it to work as I had said.
Oct 27 '09 #7
wassimdaccache
222 100+
Thanks all. I am doing the loop to lock all my control..

Regards
Oct 28 '09 #8
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Oct 28 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ethanj /personal/ | last post by:
I have main form with subform, similar to the Order Details form in the Northwind database. The the main form record locking is released when I click to edit subform's records. Is there away to...
4
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...
1
by: gleave | last post by:
Hi, I have a problem with subforms. I want to lock a subform until all the required data is inputted in the main form. The required fields in main form: Invoice Number Invoice to The main...
0
by: theBman | last post by:
I have 2 tables. One master, one child using Access 2003 (PC) Have 2 forms. The main form is continuous while the sub is datasheet. I can filter on the main form and the subform filters with...
2
by: stpark22 | last post by:
Hello, I've constructed a form that contains a subform in Access 2003. I want to be able to set the tab order to tab through the fields of the main forms then tab through the fieldw of the subform...
3
by: MGC | last post by:
I am using MS Access 97. I am trying create a log of record set additions to a table containing product inventory locations. Would like to add the date and time stamp to the just-saved data in the...
1
by: kinglioness | last post by:
Hello All, I am new to this forum so I apologize if this quesiton was asked already. Although i did search but i couldn't find. I have 2 combo boxes one unbound and the other bound they are on...
27
by: tragaz | last post by:
Hi There, I'm a beginer in Access and VB. In my Database, I've got a form with a subform. the subform is a query from a table different than the table of the main form. those tables don't have a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.