I'm trying to code a command button so that when pressed you will see a input box that will ask you if you want to change the font to bold or italic. I have that working but if you do not type nothing and hit ok it will bold everything. What am I missing from my code. If you do not type nothing in I do not want the code to run. Here is my code: Any help would be great. Thanks
Private Sub Command27_Click()
Dim strInput As String
Dim strAnswer As String
Dim frmCurrent As Form
Dim ctlControl As Control
On Error GoTo Command27_Err
strAnswer = InputBox("Enter Bold or Italic to channge the font", "Font Change")
For Each frmCurrent In Forms
For Each ctlControl In frmCurrent.Controls
If strAnswer = Left$(strAnswer, 4) Then
ctlControl.FontBold = True
Else
If strAnswer = Left$(strAnswer, 6) Then
ctlControl.FontItalic = True
Else
'do nothing
End If
End If
Next
Next
command27_Exit:
Exit Sub
Command27_Err:
If Err = 438 Then
Resume Next
Else
msgbox Error$
Resume command27_Exit
End If
End Sub
Private Sub Command27_Click()
Dim strInput As String
Dim strAnswer As String
Dim frmCurrent As Form
Dim ctlControl As Control
On Error GoTo Command27_Err
strAnswer = InputBox("Enter Bold or Italic to channge the font", "Font Change")
For Each frmCurrent In Forms
For Each ctlControl In frmCurrent.Controls
If strAnswer = Left$(strAnswer, 4) Then
ctlControl.FontBold = True
Else
If strAnswer = Left$(strAnswer, 6) Then
ctlControl.FontItalic = True
Else
'do nothing
End If
End If
Next
Next
command27_Exit:
Exit Sub
Command27_Err:
If Err = 438 Then
Resume Next
Else
msgbox Error$
Resume command27_Exit
End If
End Sub