I am a noob to VBA; I use it in Access 2003 to try and automate some junk in our d/b.
Within some forms I implemented some goofy VB password code and then tried to lock the form if the password matches:
Okay, so when I test it I can edit everything. I even went to the property sheet and manually tried turning off editing - no good. The only thing that worked programatically was setting RecordsetType = "Snapshot", but that apparently locks all my records displayed by the form and not just the one with the correct p/w.
I would think there would be an easy way to lock all the controls in a form without having to do a For ... Next loop to disable each individual control, and I have the feeling I have to do something else first before I can disable edits or there's some Acc2K3 global setting I am not twiddling.
By the way, in my travels I've learned that if I run this code:
...it won't work reliably unless I swap the .Locked and .Enabled properties. I get seemingly random results (for example, the text box will gray out when I advance to a record once but not the next two times). I did not know there was a priority to this, but I suppose it makes sense. Could this be related to my form editing errors?
I understand I'm probably doing something wrong and I am pretty much "teaching" myself VBA via the web and by having my boss yell at me to git er done yesterday. I would sincerely appreciate any comments...than ks in advance.
Within some forms I implemented some goofy VB password code and then tried to lock the form if the password matches:
Code:
If inStr = "password" Then
With Form
.AllowEdits = false
.AllowAdditions = false
.AllowDelections = false
End With
Else
... turn everything back on ...
End If
I would think there would be an easy way to lock all the controls in a form without having to do a For ... Next loop to disable each individual control, and I have the feeling I have to do something else first before I can disable edits or there's some Acc2K3 global setting I am not twiddling.
By the way, in my travels I've learned that if I run this code:
Code:
txtBox52.Enabled = False txtBox52.Locked = True
I understand I'm probably doing something wrong and I am pretty much "teaching" myself VBA via the web and by having my boss yell at me to git er done yesterday. I would sincerely appreciate any comments...than ks in advance.
Comment