Me.AllowEdits=True doesn't work

spa856

New member
Local time
Today, 18:16
Joined
Apr 21, 2023
Messages
26
Hello.
I have a problem with the edit in a form.
Private Sub Form_Current()
Me.AllowEdits = False
If IsNull(Me.ANNO_ISTANZA) Then
Me.CmdIstanza.Caption = "New Document"
Else
Me.CmdIstanza.Caption = "Modify Document"
End If
End Sub

Private Sub CmdIstanza_Click()
Dim scelta As String
If Me.PDF_created = "S" Then
MsgBox "The document is completed, you cannot edit it."
Exit Sub
Else
Me.AllowEdits = True
If Me.CmdIstanza.Caption = "New Document" Then
scelta = MsgBox("Do you want create a new document?", vbOKCancel)
If scelta = vbOK Then
Me.Year_Document = Year - 1
Me.CmdIstanza.Caption = "Modify Document"
Me.Requery
Else
Exit Sub
End If
Else
Me.AllowEdits = True
End If
End If
Me.Requery
End Sub



My issue is related the allowedit. It seems that the allowedit=false on the current event don't change.
I tried to remove it and the code in CmdIstanza_Click works well (change caption etc).
Could you please help me?
Thank you
 
Once a form is set to not allow edits, can't do anything - cannot select another record for edit and cannot click a button. So I don't see how your command button could work.
 
You call me.Requery in CmdIstanza_Click.
This causes Form.Current to be triggered.
In Form_Current() you set AllowEdits to false.
 
So the issue Is the requery?
Can i refresh the caption without requery?
 
I really hope you are indenting your code and not writing it as above, despite it being within code tags.? :(
 
I really hope you are indenting your code and not writing it as above, despite it being within code tags.? :(
??? I Always indenting my code, the tags align all to left (see screenshot)
I only asked if the issue was related to the requery.
 

Attachments

  • Screenshot_2023-05-01-19-19-08-73_40deb401b9ffe8e1df2f1cc5ba480b12.jpg
    Screenshot_2023-05-01-19-19-08-73_40deb401b9ffe8e1df2f1cc5ba480b12.jpg
    394.8 KB · Views: 112
Last edited:
Seems you aren't using CODE tags. Which icon from edit menu are you using? Use </>.
 
Can i refresh the caption without requery?
I did not think anything would be required, but try a repaint
 
It doesn't work. I solved set the property of the form to NO (allow addition, allow edit, allow delete).
Removed the code on the current event.
 

Users who are viewing this thread

Back
Top Bottom