View Single Post
 
Old 05-29-2018, 11:09 PM
kiwimtnbkr kiwimtnbkr is offline Windows 10 Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2017
Posts: 69
kiwimtnbkr is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
You will have to change the name of your form.

i.e., change the existing form named ufrmPrintNumberedCopies to frmPrintDialog.
Sorted - changed the existing forms to frmPrintNumberedCopiesAll and frmPrintNumberedCopiesSelect and then adjusted the two lines in your code from frmPrintDialog to frmPrintNumberedCopiesAll and frmPrintedNumberedCopiesSelect respectively.

The validation works bang on for the PrintNumberedCopiesAll but only kind of works for the PrintNumberedCopies select which has a 3rd text box entitled txtPages in that it validates.

I managed to adjust your code to take into account the txtPages validation but somewhat disconcertingly I am unable to put commas and hyphens into the 'what pages require printing' box to assist with specifying what pages I wanted printed.
Code:
Option Explicit
Dim m_bTest As Boolean
Private Sub txtStartNumber_Change()
  Validate_OK
End Sub
Private Sub txtPages_Change()
  Validate_OK
End Sub
Private Sub txtPages_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  m_bTest = IsInteger(KeyAscii)
  If m_bTest = False Then
    Beep
    KeyAscii = 0
  End If
End Sub
Private Sub txtStartNumber_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  m_bTest = IsInteger(KeyAscii)
  If m_bTest = False Then
    Beep
    KeyAscii = 0
  End If
End Sub
Private Sub txtCopies_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
  m_bTest = IsInteger(KeyAscii)
  If m_bTest = False Then
    Beep
    KeyAscii = 0
  End If
End Sub
Private Sub txtCopies_Change()
  Validate_OK
End Sub
Function IsInteger(ByVal i As String) As Boolean
  Select Case i  'Checking to see if inside valid Ascii range for integers
    Case 48 To 57: IsInteger = True
    Case Else: IsInteger = False
  End Select
End Function
Private Sub UserForm_Activate()
  Validate_OK
End Sub
Private Sub cmdCancel_Click()
  Tag = "CANCX"
  Hide
End Sub
Private Sub cmdOK_Click()
  Hide
End Sub
Private Sub Validate_OK()
  cmdOK.Enabled = True
  If Not IsNumeric(Trim(txtCopies)) Then cmdOK.Enabled = False
  If Not IsNumeric(Trim(txtStartNumber)) Then cmdOK.Enabled = False
  If Not IsNumeric(Trim(txtPages)) Then cmdOK.Enabled = False
End Sub
Reply With Quote