Message box show only first time

zan

Registered User.
Local time
Yesterday, 20:22
Joined
Oct 26, 2006
Messages
13
Hi guys.

I have a few problems with my message box.

1. How do I enable a message to pop up only the first time I click a save button on a new record in a form?

2. How do I run the following

Me.Home_Tel.Locked = True
Me.Student_Name.Locked = True
Me.Class_Enrolled.Locked = True

ONLY AFTER you click Yes on the message box?

After you click yes, it can be locked forever, but not before you click the save button or if you clicked No on the msg box.


3. For another command button, how do I disable it after you have clicked it, and not enable it again until after you enter some value into a text box?



My message box now:


Dim msg As String
'Ask user if they want to save the record.
msg = msg & "You cannot change Student Name and Course Enrolled after you save. Proceed? "
If MsgBox(msg, vbYesNo, "Warning") = vbYes Then
'Run the command
DoCmd.RunCommand acCmdSaveRecord
'Lock the following keys
Me.Home_Tel.Locked = True
Me.Student_Name.Locked = True
Me.Class_Enrolled.Locked = True

Else
Me.Home_Tel.Locked = False
Me.Student_Name.Locked = False
Me.Class_Enrolled.Locked = False
Exit Sub
End If
 
zan said:
Hi guys.

I have a few problems with my message box.

1. How do I enable a message to pop up only the first time I click a save button on a new record in a form?

2. How do I run the following



ONLY AFTER you click Yes on the message box?

After you click yes, it can be locked forever, but not before you click the save button or if you clicked No on the msg box.

I would think adding a Yes/No field in your table to hold the value of whether you want the 3 controls Locked or not. Then in your message box you could add in the 'Yes' part of it to make the Yes/No field true if the Saved button has been clicked. Leave it False if it hasn't. Then in the Forms On Current event to could add an If statement to see what the Yes/No fields value is. If True then Lock the 3 controls, otherwise Locked = False.



zan said:
3. For another command button, how do I disable it after you have clicked it, and not enable it again until after you enter some value into a text box?
My message box now:

You could have the command button set to Enabled = False, then in the text box After Update event you could have an If statement added to set cmdButton to Enabled = True in the text box has a value entered in it.

HTH,
Shane
 
Thanks! I solved my problem on #2.

As for #3. I know how to enable the cmdButton after I enter value in the text box, but what I want to do is disable the cmbButton again after I have clicked the cmdButton.





Anyone can shed light on how to open a msg box only the first time you click it??
 
Msgbox:

you need a flag in the module called msgseen, or something like. Initiallize to false in the open event. Then before showing the msgbox do

if not(msgseen) then
call msgbox
msgseen = true
end if


if the onclick event of the cmdbutton, you want cmdbutton.enabled=false
only trouble is you MAY not be able to disable it while you are in it.

In that case, again use a flag to determine whether cmdbutton should react to a click or not, which you can set appropraitely. You will still be able to click it, but it won't do anything, and you can even display a message.

Apparently its a but old fashioned to have buttons enabled, which then tell you, you can't do something. Its more modern to enable/disable the buttons. But it doesn't matter - whatever works really.
 
I'm not quite sure how to insert the "msgseen" you mentioned.

Btw, what I eventually did was put cmdenter.enabled=false under cmdenter_exit. It works just fine, execpt that the button will not turn gray.


Private Sub cmdEnter1_Exit(Cancel As Integer)
Me.cmdEnter1.Enabled = False
End Sub
 

Users who are viewing this thread

Back
Top Bottom