Subform Data Entry mode versus Edit mode at runtime

G

Guest

I have an unbound main form (let's call it MainForm), with a bound subform
(let's call it EntryForm). I originally designed it for data entry, so
EntryForm was set to DataEntry=yes at design time. Then, I needed to be able
to switch to data edit, so I changed the form to DataEntry=no at design time.
It's unsatisfactory when the form should be in data entry mode. Can I switch
the subform to data entry mode at run time? Or do I have to replicate the
form for each parent mode?
 
G

Guest

Jim,

You can open it in the desired mode by either using the optional DataMode
parameter of the OpenForm method (simpler if this is the only property if you
want to set--see VBA Help) or by passing an argument via the optional
OpenArgs parameter, and then set the properties you wish in the On Open event:

With Me
Select Case .OpenArgs
Case "ReadMeNoFilter"
.AllowEdits = False
.AllowAdditions = False
.AllowDeletions = False
.AllowFilters = False
Case "SomeOtherOpenArgsString"
.SomeOtherProperty = SomeValue
Case Else ' If Null, accept default property settings
End Select

Hope that helps.
Sprinks
 
G

Guest

datamode argument doesn't seem to affect the subform, only the main form
(which is unbound....) In any case, as usual, you have answered my question
well enough for me to accomplish my objective. Thanks alot!
 
G

Guest

Jim,

Ah. One possible solution is to set the subform's properties to whatever
they are in the Main form in the OnOpen event:

Me![YourSubform].Form.SomeProperty = Me.SomeProperty
Me![YourSubform].Form.SomeOtherProperty = Me.SomeOtherProperty
....

Sprinks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top