Subform Data Entry mode versus Edit mode at runtime

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
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!
 
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
 
Back
Top