View Single Post
 
Old 03-27-2019, 08:26 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not sure why the Change is not working but it only appears to fail if you tab out of the FirearmTypeComboBox - clicking to other boxes is fine. In any case, your code was changing the contents of the ResultsTextBox multiple times which was calling the second macro multiple times. I've recoded that to be more efficient.

Try changing the ResultsTextBox code to _AfterUpdate instead of _Change
Code:
Private Sub FirearmTypeComboBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)    '
  Dim aCtl As Control, sText As String
  Set aCtl = Me.ResultsTextBox
  
  Select Case Me.RestorationTypeComboBox
    Case "Successful Restoration"
      sText = "Examination and [magnetic and/or chemical] processing of the aaa bbb restored the original obliterated serial number which was determined to be 'ccc'."
      sText = Replace(sText, "ccc", RestoredCharactersTextBox.Value)
    Case "Partial Restoration"
      sText = "Examination and [magnetic and/or chemical] processing of the aaa bbb partially restored the original obliterated serial number which was determined to be ccc."
      sText = Replace(sText, "ccc", RestoredCharactersTextBox.Value)
    Case "Unsuccessful Restoration"
      sText = "Examination and [magnetic and/or chemical] processing of the aaa bbb failed to restore any part of the serial number."
  End Select
  
  sText = Replace(sText, "aaa", ItemComboBox.Value)
  sText = Replace(sText, "bbb", FirearmTypeComboBox.Value)
  Me.ResultsTextBox = sText
End Sub

Private Sub ResultsTextBox_AfterUpdate()
  With Me.ResultsTextBox
    .SetFocus
    .SelStart = 0
    .SelLength = Len(.Text)
    If .LineCount > 1 Then
      .Height = ((.LineCount - 2) * 13.5) + 33
      SNRCommandButton.Top = .Top + .Height + 22.5
      SNRUserForm.ScrollHeight = SNRCommandButton.Top + SNRCommandButton.Height + 28
    Else
      .Height = 19.5
      SNRCommandButton.Top = .Top + .Height + 22.5
      SNRUserForm.ScrollHeight = SNRCommandButton.Top + SNRCommandButton.Height + 28
    End If
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote