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

Form "ReadOnly"

P: 51
Hi,
since assigned "acFormReadOnly", my code supposes to allow user to only "read the form", but when I test the code, I can type and click on any of the fields on the form. What I really want the code to do is not allow user to be able to click or type on any of the fields, on the form. Any idea? please help.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim db As Database
  3.     Dim rst As Recordset
  4.     Dim stLinkCriteria As String
  5.  
  6.     Set db = CurrentDb
  7.     Set rst = db.OpenRecordset("tblReview", dbOpenDynaset)
  8.     rst.FindFirst "[ID] = " & Me![txtRECID] & ""
  9.     stLinkCriteria = "[ID]=" & Me![txtRECID]
  10.     DoCmd.OpenForm "frmReview", , , stLinkCriteria, acFormReadOnly
  11.  
thanks!
Sep 25 '08 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,470
Opening the form ReadOnly only stops you updating the data. It doesn't disable the functionality of the controls on the form.

To do this loop through all the controls and set them to disabled. Some code similar to the following would be required :
Expand|Select|Wrap|Line Numbers
  1. Dim ctlMe As Control
  2.  
  3. On Error Resume Next
  4. For Each ctlMe in Me.Controls
  5.   ctlMe.Enabled = False
  6. Next ctlMe
  7. On Error GoTo 0
This all assumes you can't simply set them all from Design-mode. If that's possible it's much easier. Unfortunately, even .Locked controls still drop down even though their values won't change.
Sep 25 '08 #2

P: 51
thanks for your help. Is there a way to do ViewOnly instead of ReadOnly?
thanks!

elaine
Sep 25 '08 #3

100+
P: 167
Try using:
Expand|Select|Wrap|Line Numbers
  1. Set rst = db.OpenRecordset("tblReview", dbOpenSnapshot)
Sep 25 '08 #4

NeoPa
Expert Mod 15k+
P: 31,470
Elaine, you're not being very clear about what you need here I'm afraid.

There is no way to set an otherwise updatable form to read/only simply by setting something in the form. At least not so that the ComboBox controls are disabled from opening. Opening it with DataMode:=AcFormOpenDataMode will ensure the data isn't changed, but the ComboBoxes will still drop down

To stop them dropping down they need to be set .Enabled = False. This will also show them as dimmed on a grey background.

I hope this answers your question. If not, please specify it a little more clearly & I will be better able to help.
Sep 25 '08 #5

DonRayner
Expert 100+
P: 489
Add your form as a subform on a new form. Delete the subform label and set the subform properties as follows

Special Effect = Flat
Border Style = Transperent
Enabled = No

This will do exactly what you are asking. User will not be able to click onto anything contained in that subform.
Sep 25 '08 #6

Post your reply

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