Open Form as either edit or read only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list of records that have a "no Revision Allowed" check box. I would
like to use a list box so the user can select a record and then open it up in
a form. However, records with the "no revision allowed" checked should be
open up in the form as read only. The others can be opened as editable. Any
help is appreciated
 
Take a look at the "Allow Edits", "Allow Deletions" and "Allow Additions"
properties of the form. You can check the value of the "no Revision Allowed"
check box in current record and then set these properties of your form based
on that value.
 
Crane said:
I have a list of records that have a "no Revision Allowed" check box. I would
like to use a list box so the user can select a record and then open it up in
a form. However, records with the "no revision allowed" checked should be
open up in the form as read only. The others can be opened as editable. Any
help is appreciated


Check VBA Help on the OpenForm method and its DataMode
argument.

If Me.[no Revision Allowed] = False Then
DoCmd.OpenForm "the form", _
DataMode:=acFormEdit,
WhereCondition:= "pkfield=" & Me.pkfield
Else
DoCmd.OpenForm "the form", _
DataMode:= acFormReadOnly,
WhereCondition:= "pkfield=" & Me.pkfield
End If
 
i understand what you are getting at but am not sure how to combine with what
i already have. Originally my plan was to have two forms one with items that
could be edited and another that could not and open accordingly. But i came
across this bit of code and adapted to my problem but am still going to be
stuck with two forms.

Private Sub cmdsome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box

If Me!listcmrequests.ItemsSelected.Count = 0 Then Exit Sub

For Each varItem In Me!listcmrequests.ItemsSelected

strWhere = strWhere & Me!listcmrequests.Column(0, varItem) & ","
Next varItem

strWhere = Left$(strWhere, Len(strWhere) - 1)


strWhere = "[CMRID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="qrycminfo", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub

--
Crane


Marshall Barton said:
Crane said:
I have a list of records that have a "no Revision Allowed" check box. I would
like to use a list box so the user can select a record and then open it up in
a form. However, records with the "no revision allowed" checked should be
open up in the form as read only. The others can be opened as editable. Any
help is appreciated


Check VBA Help on the OpenForm method and its DataMode
argument.

If Me.[no Revision Allowed] = False Then
DoCmd.OpenForm "the form", _
DataMode:=acFormEdit,
WhereCondition:= "pkfield=" & Me.pkfield
Else
DoCmd.OpenForm "the form", _
DataMode:= acFormReadOnly,
WhereCondition:= "pkfield=" & Me.pkfield
End If
 
Crane said:
i understand what you are getting at but am not sure how to combine with what
i already have. Originally my plan was to have two forms one with items that
could be edited and another that could not and open accordingly. But i came
across this bit of code and adapted to my problem but am still going to be
stuck with two forms.

Private Sub cmdsome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box

If Me!listcmrequests.ItemsSelected.Count = 0 Then Exit Sub

For Each varItem In Me!listcmrequests.ItemsSelected

strWhere = strWhere & Me!listcmrequests.Column(0, varItem) & ","
Next varItem

strWhere = Left$(strWhere, Len(strWhere) - 1)


strWhere = "[CMRID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="qrycminfo", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub


Ahh, now I see where you're going. Go back to Mr B's idea
and add this to the form's Current event:
Me.AllowEdits = Not Me.[no Revision Allowed]
 
Thank you both.. i Finally got it to work... This group will be a lifesaver
and a fine opportunity to learn
--
Crane


Marshall Barton said:
Crane said:
i understand what you are getting at but am not sure how to combine with what
i already have. Originally my plan was to have two forms one with items that
could be edited and another that could not and open accordingly. But i came
across this bit of code and adapted to my problem but am still going to be
stuck with two forms.

Private Sub cmdsome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box

If Me!listcmrequests.ItemsSelected.Count = 0 Then Exit Sub

For Each varItem In Me!listcmrequests.ItemsSelected

strWhere = strWhere & Me!listcmrequests.Column(0, varItem) & ","
Next varItem

strWhere = Left$(strWhere, Len(strWhere) - 1)


strWhere = "[CMRID] IN (" & strWhere & ")"
DoCmd.OpenForm FormName:="qrycminfo", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub


Ahh, now I see where you're going. Go back to Mr B's idea
and add this to the form's Current event:
Me.AllowEdits = Not Me.[no Revision Allowed]
 
Back
Top