Changing Hour/Min/AM-PM

M

Mark

I have a textbox for Hour, a textbox for Minute, a textbox for AM/PM and an up
button and down button to increment/decrement the values in the textboxes. I
have the code to increment/decrement all three, what I need is a way to tell the
buttons which textbox to increment/decrement. Can anyone help.

Thanks!

Mark
 
J

John Nurick

Hi Mark,

Suppose you click on the Hour textbox and then on the Up button. The
button takes the focus from the textbox, but Screen.PreviousControl
still points to it. Try something like this (untested air code) in the
beginning of the buttons' Click() event procedures:

Dim ctlC As Control

Set ctlC = Screen.PreviousControl
ctlC.SetFocus
Select Case ctlC.Name
Case "txtHour", "txtMinute"
'code here to increment or decrement
With ctlC

End With
Case "txtAMPM"
'code to change from AM to PM or vice versa
With ctlC

End With
Case Else
'button was pressed when some other control
'had focus: do nothing
End Select
Set ctlC = Nothing
 

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