Lock Form after press a button

A

Adamfunchal

Hello
I have a form with a button to send him by e-mail to another person. When I
press that Button it opens a Report and send this report by mail. Now my
question is:
Its possible lock that form after press "e-mailButton" and its successfully
send by mail?Could that e-mailButton be used again when I press "New
Registry" with new auto number?
 
S

Scott McDaniel

Hello
I have a form with a button to send him by e-mail to another person. When I
press that Button it opens a Report and send this report by mail. Now my
question is:
Its possible lock that form after press "e-mailButton" and its successfully
send by mail?Could that e-mailButton be used again when I press "New
Registry" with new auto number?

You can "lock" the form by setting the AllowAdditions, AllowEdits, and AllowDeletions property of the form as needed.
You'd do this AFTER the email is sent:

<your email code>
Me.AllowEdits=False
Me.AllowDeletions=False

You'd need to reset those properties in the Form's Current event, however, in order for users to be able to interact
with other records (if that's relevant).

However, if you want to "save" this setting, you'll need some column in your table that lets you know when the email has
been sent ... for example, if you have a dteEmailSent field to store the date, you could check that in the Current event
and see if the form needs to be "locked".



Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
A

Adamfunchal

Hello
I've this code for the "emailButton"
Private Sub Comando37_Click()
On Error GoTo Err_Comando37_Click

Dim stDocName As String

stDocName = "Enviar por correio"
DoCmd.RunMacro stDocName
Me.AllowEdits = False
Me.AllowDeletions = False

Exit_Comando37_Click:
Exit Sub

Err_Comando37_Click:
MsgBox Err.Description
Resume Exit_Comando37_Click

End Sub

And its not working correctly. After press "Commando37" (emailButton) I can
Edit, delete or whatever I want.
Whats Wrong?


"Scott McDaniel" escreveu:
 
S

Scott McDaniel

Hello
I've this code for the "emailButton"
Private Sub Comando37_Click()
On Error GoTo Err_Comando37_Click

Dim stDocName As String

stDocName = "Enviar por correio"
DoCmd.RunMacro stDocName
Me.AllowEdits = False
Me.AllowDeletions = False

Exit_Comando37_Click:
Exit Sub

Err_Comando37_Click:
MsgBox Err.Description
Resume Exit_Comando37_Click

End Sub

And its not working correctly. After press "Commando37" (emailButton) I can
Edit, delete or whatever I want.
Whats Wrong?

What does your macro "stDocName" do?

The code you have listed would NOT allow Edits or Deletions, but would allow new records to be added.

If you'd rather, you could instead disable and lock all controls after running your macro:

Dim ctl As Control

On Error Resume Next
For each ctl in Me.Controls
ctl.Enabled = False
ctl.Locked = True
Next ctl


Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
A

Adamfunchal

"What does your macro "stDocName" do?"
this macro opens a report and then send that report by e-mail.
I tried this code:
Dim ctl As Control

On Error Resume Next
For each ctl in Me.Controls
ctl.Enabled = False
ctl.Locked = True
Next ctl


But it locks everything after "send by mail" but I want to insert a new
registry with new "auto number" and then send again by e-mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top