By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Is form read-only?

Expert 100+
P: 218
Mebbe I need a new brain....

I need to check if a form is open in read-only mode.

I open it with:-
Expand|Select|Wrap|Line Numbers
  1.     If InVal = 150 Then
  2.         DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
  3.     Else
  4.         DoCmd.OpenForm stDocName, , , stLinkCriteria
  5.     End If
  6.  
What do I need to do to check the open mode from within the opened form?

TIA

Steve
Nov 15 '06 #1
Share this Question
Share on Google+
6 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3.   If Me.AllowEdits = False And Me.AllowDeletions = False And Me.AllowAdditions = False Then
  4.     MsgBox "This form is open in read only mode", vbInformation
  5.   End If
  6. End Sub
  7.  
Mebbe I need a new brain....

I need to check if a form is open in read-only mode.

I open it with:-
Expand|Select|Wrap|Line Numbers
  1. If InVal = 150 Then
  2. DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
  3. Else
  4. DoCmd.OpenForm stDocName, , , stLinkCriteria
  5. End If
  6.  
What do I need to do to check the open mode from within the opened form?

TIA

Steve
Nov 15 '06 #2

NeoPa
Expert Mod 15k+
P: 31,489
I don't think there is a ReadOnly mode as such.
I think this parameter sets those modes (that Mary suggests to check) instead.

DataMode Optional AcFormOpenDataMode. The data entry mode for the form. This applies only to forms opened in Form view or Datasheet view

AcFormOpenDataMode can be one of these AcFormOpenDataMode constants.
acFormAdd The user can add new records but can't edit existing records.
acFormEdit The user can edit existing records and add new records.
acFormPropertySettings default
acFormReadOnly The user can only view records.
If you leave this argument blank (the default constant, acFormPropertySettings, is assumed), Microsoft Access opens the form in the data mode set by the form's AllowEdits, AllowDeletions, AllowAdditions, and DataEntry properties.
Nov 16 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
I don't think there is a ReadOnly mode as such.
I think this parameter sets those modes (that Mary suggests to check) instead.
More or less.

Access, as usual, puts names like this on what is essentially a collection of property values. It sets its read only mode to disallow these features. If all are false the form is read only.

Mary
Nov 16 '06 #4

Expert 100+
P: 218
Thanks to all

My problem was that, although I was opening the form as read-only, there was a delete button (added by another colleague!), which was still active - hence my need to check...

Unfortunately, this particular form is an utter b#'*d in that it can be in almost any combination of states.

It's working now, tho'.

Steve
Nov 16 '06 #5

ADezii
Expert 5K+
P: 8,637
Mebbe I need a new brain....

I need to check if a form is open in read-only mode.

I open it with:-
Expand|Select|Wrap|Line Numbers
  1.     If InVal = 150 Then
  2.         DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
  3.     Else
  4.         DoCmd.OpenForm stDocName, , , stLinkCriteria
  5.     End If
  6.  
What do I need to do to check the open mode from within the opened form?

TIA

Steve
How about something as simply as using the OpenArgs property of the Form and passing the Form's Open Mode

Expand|Select|Wrap|Line Numbers
  1. If InVal = 150 Then
  2. DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly, "Read Only"
  3. Else
  4. DoCmd.OpenForm stDocName, , , stLinkCriteria, "View_Edit"
  5. End If
'In the Form_Open() Event
Expand|Select|Wrap|Line Numbers
  1. If Me.OpenArgs = "Read Only" Then
  2.     'Relavant code here
  3. ElseIf Me.OpenArgs = "View_Edit" Then
  4.     'Relavant code here
  5. Else
  6.     'Relavant code here
  7. End If
Nov 17 '06 #6

NeoPa
Expert Mod 15k+
P: 31,489
If there's no way of enquiring from Access itself (and I think there's not) then OpenArgs is a good solution.
Nov 18 '06 #7

Post your reply

Sign in to post your reply or Sign up for a free account.