Display USERFORM with updated text ...

  Heefie 17:31 24 Dec 2004

I'm writing an EXCEL VBA module and am trying to use a USERFORM to display Error Messages.

The USERFORM is called FormErrorMessage and it contains a single TEXTBOX, called TxtErrorMessage, and an OK key.

If I put a value, 'XXX' for example into the VALUE field while in Design Mode, the 'XXX' value displays in the TEXTBOX as I'd expect.

So, in my module, if I code :

If MySession > "" Then
TxtErrorMessage = "You have an error"
End If


If MySession > "" Then
TxtErrorMessage.Value = "You have an error"
End If

Why do I get nothing in the TEXTBOX ?!?!

Do I have to refresh the USERFORM data or something ... this is so frustrating !!!!!!

  VoG II 18:03 24 Dec 2004

A TextBox is meant to get information from the user into the program, not the other way round.

You would be better off adding a Label (The A button). you can then change the label programatically e.g.

UserFirm1.Label1.Caption = "Heelp - Error"

However I prefer using MsgBoxes to display error messages:


If Not Liquid And Not Life Then

Response = MsgBox(Title:="Product is Solid with >1 year life", prompt:="Perform ERA?", Buttons:=vbQuestion + vbYesNo + vbDefaultButton2)

If Response = vbNo Then Exit Sub

End If


MsgBox prompt:="Missing product name: Abort", Title:="Output sheet validation", Buttons:=vbCritical


If Not CASOK Then


MsgBox prompt:="Invalid CAS Number: " & CASNo, Title:="CAS Number validation", Buttons:=vbExclamation

End If

  Heefie 18:09 24 Dec 2004

Another thing I've learned today !!!

I did think this seemed a long winded way of outputting an error message, thanks for that VoG™ ...

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

iMac Pro review

Illustrator of witty, relatable Instagram comics Julia Bernhard touches on our humble moments

iMac Pro review

Quelle est la meilleure application de podcast pour Android (2018) ?