sendKeys enter key to a message box with yes /no fields.

virencm

Registered User.
Local time
Today, 22:09
Joined
Nov 13, 2009
Messages
61
Hi

how do i send an enter key command to a msgbox with yes / no fields.. it automatically defaults to yes and i just need the enter key pressed without actually manually pressing ..

my application automatically shuts all open databases if i want to make changes. i have to change the 0 to a -1 and it automatically triggers a timer .. my main form has a quit.. message box on unload event. so after it counts down to 0 it stops at the message box and waits for me to manually press enter. how can i bypass this???

i want this to work only when i want to log users off..
 
if this is a message box to confirm a log off, i think you should leave it in place. almost all systems have a confirmation like this. regardless though, i believe the sendkeys syntax for enter is:
PHP:
sendkeys "{ENTER}"
 
Hi Adam

I ve tried the sendkeys "{enter}"..& it doesnt seem to work.
i want to keep the message to confirm a log off, except when i want to log off users to fix an issue. at the moment if i want to log users off , the message box pops up and waits for a yes/no.

Viren
 
Hi Adam

I ve tried the sendkeys "{enter}"..& it doesnt seem to work.
i want to keep the message to confirm a log off, except when i want to log off users to fix an issue. at the moment if i want to log users off , the message box pops up and waits for a yes/no.

Viren

Try something like the following in your Form_Unload event:
Code:
[COLOR="Navy"]Private Sub[/COLOR] Form_Unload(Cancel [COLOR="navy"]As Integer[/COLOR])
 
    [COLOR="navy"]Dim[/COLOR] sQuestion [COLOR="navy"]As String
 
    If[/COLOR] Me.TimerInterval = 0 [COLOR="navy"]Then[/COLOR]
        sQuestion = "Are you sure you want to log off?"
        [COLOR="navy"]If[/COLOR] MsgBox(sQuestion, vbQuestion + vbYesNo) = vbNo [COLOR="navy"]Then[/COLOR]
            Cancel = [COLOR="navy"]True
        End If
    End If
 
End Sub[/COLOR]
That way, if you have the timer interval set, the question never even appears. See if this solution works for you.
 
Last edited:
myzer's solution is the best I think, but you would have to set the timer interval before doing it I suppose. alternatively, you could use the timer() function to set the number of seconds or a countdown mechanism to the logoff time, if that makes sense.
 

Users who are viewing this thread

Back
Top Bottom