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

How to set a property of a subform from the main form 1

Status
Not open for further replies.

Callreluctance

Technical User
Jan 3, 2003
25
US
I am trying to create an opening form (replacing the switchboard). I want to open a contact form and set it to view only. I will create another button to open the same contact form to allow editing, and another button to set the same form to data entry. The main form is called Main View and the subform is called Contacts. I am trying to avoid having to create three forms to do the same thing.
 
me.MainFormSubFormControlName.Form.AllowEdits = False, etc.
Note that you have to reference the subform container control on the main form and then its form property to get there.

If you look at the controls collection for your main form, you will see the subform container control name.

It might help you to think about it as being similar to the way a textbox has an attached label which you can access via the textboxname controls collection. Hope this helps instead of making things worse.

Good Luck!

 
Do I set this up in the onclick procedure, or from where do I call this?
 
There are 3 properties on the Data tab for form properties:
AllowEdits, AllowDeletions and AllowAdditions. You are correct, set them up as you need to in the click events for your command buttons.

Good Luck!
 
I am getting errors using the code. Here is what I have:
The Main Form is MainPage and the form I want to call (and specify the controls for) is Contacts. The control button is MainViewContacts.

Private Sub MainViewContacts_Click()
On Error GoTo Err_MainViewContacts_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Contacts"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.MainViewContacts.Contacts.AllowEdits = False

Exit_MainViewContacts_Click:
Exit Sub

Err_MainViewContacts_Click:
MsgBox Err.Description
Resume Exit_MainViewContacts_Click

End Sub

Thanks again.

Also, how do you make the subject line bold in the Forum?

Jim
 
Hey, I figured it out, just a little syntax problem. Here is the correct scripting

Forms!Contacts.AllowEdits = False
Forms!Contacts.AllowAdditions = False
Forms!Contacts.AllowDeletions = False

The same would work for Data Entry by doing:

Forms!Contacts.DataEntry = True

I also found that in the OpenForm function you can call to specific intrinsic values, in the DataMode

acFormAdd
acFormEdit
acFormPropertySettings (default)
acFormReadOnly

I hope this helps anyone else. Sharon thanks for your help in pointing me in the right direction.

Jim.
 
I apologize for the use of a name you don't have (to my knowledge). At one time I was responding to two posts in rapid succession, and both you and the responder to my other posts, handle started with S, and the other poster signed it Sharon, my brain did not do the switch. My apologies, and my thanks for the help.. [blush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top