Sub Form Properties

Luddite Lad

Registered User.
Local time
Tomorrow, 06:46
Joined
Aug 23, 2005
Messages
177
I have a form/subform ([FRM_Item] and it's subform [FRM_ItemPrice]) set that are set as no addition no edits as the default view.

what additions do I need to make to the following code to get the Subform [FRM_ItemPrice] to open in acFormEdit Mode

Dim stDocName As String

stDocName = "FRM_Item"

DoCmd.OpenForm stDocName, , , , acFormEdit
 
Last edited:
Sorry on two counts :o

Firstly whilst I can see what the piece of code proposed by Rich will do I'm not sure where it should go; and perhaps that has got to do with my not explaining my self properly. Or more likely my very sketchy understanding of VBA :(

Secondly, I didn't mention in my first post that the code resides in the on click function of a button that will open the form/subform set to allow edits and additions to the data. The form set is at other times set so that edits and additions can not be made.
 
Look up the OpenForm method in the Help file, if you leave the argument blank the form will open in the Normal mode
 
Thanks Rich

Yes I had already realised that I need to put the argument acFormEdit in the expression (check my code), and that works fine on the main form, however it has no effect on the sub form. My question is how do I also apply that expression to the sub form within the main form? I'm sure it's not that difficult I just can't see any example of the syntax.

Sorry if I seem obtuse.
 
OK I think I see were we are headed, the code now looks like this;

stDocName = "FRM_Item"
DoCmd.OpenForm stDocName, , , , acFormEdit
Me![FRM_ItemPrice].AllowEdits = True

But I'm getting an error message saying that "MSA can't find the field 'FRM_ItemPrice' reffered to in the expression" I've tried a couple of variations on the theme but can't work out how to let it know it's looking for a subform rather than a field.
 
OK I've disovered how to refer to the subform, but there is still something wrong with the code, which looks like this;

stDocName = "FRM_Item"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , , acFormEdit
Forms![FRM_Item]![FRM_ItemPrice].AllowEdits = True

I'm now getting an "Object doesn't support this property or method"

Arrrrrgh Help.
 
Yes I know I'm thick but could someone pleaser put me out of my misery.
 
Mr. Lad try this

Add an OpenArg "Edit" to your DoCmd.OpenForm line. Then in the On Load event of the main form add the following test;

If Me.OpenArgs = "Edit" Then
Me.frmSubForm.Form.AllowAdditions = True
Me.frmSubForm.Form.AllowEdits = True
Me.frmSubForm.Form.AllowDeletions = True
End If​

Insert the name of your sub form at frmSubForm

I think you'll find it should do what you want.

P.S. It's not your fault you are a Luddite after all :D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom