Display USERFORM with updated text ...

  Heefie 17:31 24 Dec 04
Locked

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"
FormErrorMessage.Show
End
End If

or

If MySession > "" Then
TxtErrorMessage.Value = "You have an error"
FormErrorMessage.Show
End
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 04

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

Beep

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

End If

  Heefie 18:09 24 Dec 04

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.

Best phone camera 2016/2017: Galaxy S7 vs iPhone 7 vs Google Pixel vs HTC 10 Evo vs OnePlus 3T vs…

1995-2015: How technology has changed the world in 20 years

These are the Best Christmas Ads and Studio Projects of 2016

Super Mario Run preview | Hands-on first impressions of Super Mario Run: Mario's iPhone & iPad…