ACC2: No "Can't Add Records" Data Mode Arg. for OpenFormID: Q129301
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you set the OpenForm macro action's Data Mode argument, you can
select Add, Edit, or Read Only, but the Can't Add Records option that you
can select for the form's DefaultEditing property is not available.
To work around this behavior, use Access Basic code to pass the specified DefaultEditing property setting in the OpenArgs argument and set the property in the form's Load event. See the "More Information" section for an example of how to use the OpenArgs argument.
This behavior is by design.
The following example demonstrates how you can use the OpenForm macro
action's OpenArgs argument to pass the specified data mode for use in
a form. By using this argument, you can open a form with the Can't Add
Records data mode.
CAUTION: Following the steps in this example will modify the sample
database NWIND.MDB. You may want to back up the NWIND.MDB file, or
perform these steps on a copy of the NWIND database.
Sub Form_Load (Cancel As Integer)
' Set the DefaultEditing property to the value passed in the
' OpenArgs argument.
Me.DefaultEditing = Me.OpenArgs
End Sub
1 = Data Entry
2 = Allow Edits
3 = Read Only
4 = Can't Add Records
Sub Form_Load ()
Dim iSemicolon As Integer
Dim iDefaultEditing As Integer
Dim sWhereCondition As String
' Find the semicolon.
iSemicolon = InStr(Me.OpenArgs, ";")
' If the semicolon is found...
If iSemicolon > 0 Then
'...parse the DefaultEditing and Where Condition arguments...
iDefaultEditing = Left(Me.OpenArgs, iSemicolon - 1)
sWhereCondition = Mid(Me.OpenArgs, iSemicolon + 1)
'...and set the arguments.
Me.DefaultEditing = iDefaultEditing
If sWhereCondition <> "" Then
DoCmd ApplyFilter , sWhereCondition
End If
End If
End Sub
For more information about the DefaultEditing property, search for
"DefaultEditing," and then "AllowEditing, DefaultEditing Properties" using
the Microsoft Access Help menu.
Keywords : kbusage FmsProp
Version : 2.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 9, 1999