allowdeletions not working - please help

krowe

Registered User.
Local time
Today, 02:34
Joined
Mar 29, 2011
Messages
159
hi

I have my database forms set to not allow deletions, because in my experience people tend to do this by accident.

I have since found myself haveing to do more systems admin than I would like, and trying to set up a way to allow others to delete under certain cicumstances.

I have set up a form with 1 control, password
there is a button to then open my Main form and set the allowdeletions property to True. I then needd to do the same with a number of subforms.

Here is the code so far:

Code:
Private Sub Command2_Click()
If [Password] = "edit" Then
    DoCmd.OpenForm "frmMain"
    Forms!frmMain.SetFocus
    Me.AllowDeletions = True
    Forms!frmMain!sformCasenotes.SetFocus
    Me.AllowDeletions = True
Else
    MsgBox "password incorrect", , "Password Incorrect"
End If
End Sub

the form opens fine (providing the password is "edit") but the allowdeletions property does not change.

Is my method wrong in any way?

Thanks

Kev
 
Yes; "Me" always refers to the form the code is in, not the form with focus.
 
thanks

I am now making progress with this

on my password form i now have this code:

Code:
Private Sub Command2_Click()
If [Password] = "edit" Then
    DoCmd.OpenForm "frmMain"
 
Else
    MsgBox "password incorrect", , "Password Incorrect"
End If
End Sub

I have put on the OnCurrent event of frmMain this code:

Code:
If Forms!frmPassword.Form!Password = "edit" Then
    Me.AllowDeletions = True
    Me.sformCasenotes.Form.AllowEdits = True

I now have a couple of problems

If i try to open frmMain normally it throws up an error, as frmPassword is not open.

Also it seems to be allowing deletions even if edit hasn't been entered into the field in frmPassword.

Finally, it still wont work for the subform (could this be because the subform is in a tab control or because the subform is a continuous form?)

Can anyone help further please????

Thanks again for your help
 
Last edited:
Is Password the name of a textbox on that form? If so, try

If Forms!frmPassword.Password = "edit" Then
 
Hi

Thanks for your help so far. I now have this code on the onload event of frmMain:

Code:
DoCmd.OpenForm "frmPassword"
If Forms!frmPassword.Password = "edit" Then
    Me.AllowDeletions = True
    Me.sformCasenotes.Form.AllowEdits = True
    DoCmd.Close acForm, "frmPassword", acSaveYes
    
    Else
    Me.AllowDeletions = False
    Me.sformCasenotes.Form.AllowEdits = False
    DoCmd.Close acForm, "frmPassword", acSaveYes
    End If

It seems to be working well. The only thing that doesn't work is the allowdeletions on the subform.

could it be because it is a continuous form, or because it is on a tab control?
 
ok, sorted it, just notice my clanger

allowedits is not allowdeletions!!!!

thanks for your help
 
Glad you got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom