Prevent the user from editing records (1 Viewer)

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
Hey guys..

is there any way in which i can prevent the user operating a form from adding or deleting or editing any records ?
 

Mile-O

Back once again...
Local time
Today, 08:21
Joined
Dec 10, 2002
Messages
11,316
Look at the form's properties. There are such properties as AllowEdits, AllowAdditions, and AllowDeletes. Set these to No.
 

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
but there are certain feilds that i want the user to edit, such as a YES/NO button, that is linked to 2 queries. so.. how would i be able to do that ?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:21
Joined
Jul 9, 2003
Messages
16,426
still_rookie said:
but there are certain feilds that i want the user to edit, such as a YES/NO button, that is linked to 2 queries. so.. how would i be able to do that ?

Do you mean YES/NO Check box instead of button?

fLockAll Will lock all your controls and the other code will unlock them. Also you can unlock individual controls are shown. The reverse is true you can lock individual controls the same.

Code:
Public Sub fLockAll()
On Error GoTo fLockAll_Err
    Dim I As Integer
    
    For I = 0 To (Me.Controls.Count - 1)
        Me.Controls.Item(I).Locked = True
    Next
    
fLockAll_Exit:
    Exit Sub
fLockAll_Err:
    'If Err.Number = 438 Or Err.Number = 2448 Then
        Resume Next
    'End If
    MsgBox Err.Description, , conAppName & "  -  Error Number " & Err.Number
    Resume fLockAll_Exit
    Resume
End Sub

Public Sub fUnLockAll()
On Error GoTo fUnLockAll_Err
    Dim I As Integer
    
    For I = 0 To (Me.Controls.Count - 1)
        Me.Controls.Item(I).Locked = False
    Next
    
fUnLockAll_Exit:
    Exit Sub
fUnLockAll_Err:
    'If Err.Number = 438 Or Err.Number = 2448 Then
        Resume Next
    'End If
    MsgBox Err.Description, , conAppName & "  -  Error Number " & Err.Number
    Resume fUnLockAll_Exit
    Resume
End Sub

You can unlock individual controls like this:



chkYesNo.Locked = False

Put the code in a command button routine.
 

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
oh thanks a lot ! .. now thats what i call a reply ;)

but could you give me a pseudo-code for this too, because i have no idea how it works lol .... ;) more importantly, i dont know how to write pseudo codes, so if you could give me 1 for this, or post it in the pseudo thread, it would be wonderful :)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:21
Joined
Jul 9, 2003
Messages
16,426
You keep harping on about this pseudo code, Stewart has already provided you with a google to many web sites that show information about pseudo code. Have you taken the time and trouble to read them?

As far as I am concerned pseudo code is where you say what you want to happen!

For example you might say "if a customer has records then open report "

now the code for this would be something like:

If Cust Recordcount > 0 then
docmd.open.Report
End If

I can't see what pseudo code has got to do with helping you use the above sample code I have provided. All you need to do is place a command button on your form and put the above code , in it.

In this situation what I usually do is call up the command button wizard and have it create the "close form" code. Then I just go into the code behind the form find the code generated for the command button and replace the single line of code that closes the form something like "docmd.Close" with the code I want to use. In your case it will be one of the functions shown above, either the lock or either the unlock function (not both) and if you want to lock or unlock individual controls then create a similar command button and just add the individual line of code two enable or disable whichever controls you want.
 

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
if you read my post there, i said i had already googgled before stewart gave me the link :confused: .. atleast i hinted it...

but as i said before, the pseudo code is not gonna help me... im doing it because i HAVE TO do it, or they cut my marks.. get it ?

it doesn't help me in any way, i dont even know how to write them, but i somewhat do after you gave me an example...
 

RV

Registered User.
Local time
Today, 08:21
Joined
Feb 8, 2002
Messages
1,115

It's 'bout time you "get it".

Uncle Gizmo provided you with a good and working solution.
Try to understand the solution (yes, that will take some effort from your side), implement and of you go.

Cutting your marks?
That's your prob mate by not taking good advice.

Good luck.

RV
 

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
Uncle Gizmo provided you with a good and working solution.
Try to understand the solution (yes, that will take some effort from your side), implement and of you go.

yeah already done that buddy...

It's 'bout time you "get it".

why me? what have i said ? i wasn't even trying to be rude there :confused:
 

RV

Registered User.
Local time
Today, 08:21
Joined
Feb 8, 2002
Messages
1,115
why me? what have i said ?

It's your attitude mate, it sucks.
If you want to improve, grow up, get experienced, whatever, main part is that you investigate in you yourself and not pushing others to investigate in you.

That's how it works for all of us, you're not different.

So, if it is your intention to improve et cetera, you should really reconsider your communication skills.
Perhaps it's not your intention to "annoy" other but hey, really, you do...

RV
 

still_rookie

Registered User.
Local time
Today, 10:21
Joined
Apr 17, 2005
Messages
122
fine watever mate ............ i figured it out myself anyway... and it ddnt need a VB code ...

cheers
 

Users who are viewing this thread

Top Bottom