keypress on a userform (with code)

P

Peter

Yes I do. Here it is. (BTW Sorry to not include it in my first post)

<Beginning of code in the module for the Userform>

Option Explicit
Const CONCERNING As String = "Concerning: "
Const OPTIONBUTTON1TXT As String = "optionbutton 1 text "
Const OPTIONBUTTON2TEXT As String = "optionbutton 2 text "
Dim sConcerning As String


Private Sub tbNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If obOptionButtonOne Then
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
Else
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
End If
tbReference = sConcerning
End Sub


Private Sub obOptionBttn1_Click()
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
tbNumber.SetFocus
End Sub


Private Sub obOptionBttn2_Click()
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
tbNumber.SetFocus
End Sub

<End of code>

Greetings,

Peter
 
B

Bob Phillips

Peter,

How about this

Option Explicit

Const CONCERNING As String = "Concerning: "
Const OPTIONBUTTON1TXT As String = "optionbutton 1 text "
Const OPTIONBUTTON2TXT As String = "optionbutton 2 text "
Dim sConcerning As String

Private Sub tbNumber_Change()
If obOptionBttn1 Then
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
Else
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
End If
tbReference = sConcerning
End Sub


Private Sub obOptionBttn1_Click()
sConcerning = CONCERNING & OPTIONBUTTON1TXT & tbNumber
tbNumber.SetFocus
End Sub


Private Sub obOptionBttn2_Click()
sConcerning = CONCERNING & OPTIONBUTTON2TXT & tbNumber
tbNumber.SetFocus
End Sub
 

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