View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
salgud salgud is offline
external usenet poster
 
Posts: 219
Default Getting text string into userform

On Thu, 31 Jul 2008 18:04:01 -0700, JLGWhiz wrote:

Well, I don't know what to tell you. I created a UserForm, put a label on it
and put the code below in the initialize event of the form. I had to give
sTRID a phony value but the message appeared as the caption of the label when
I called the form from the standard module with the UserForm1.Show method.
There was a typo in my original snippet where I used Private Sub
UserForm1_Initialize. The one does not belong there for this usage. Sorry
about that. Try pasting the code below, as is, into the UserForm code window
and see if you still get the error message.

Private Sub UserForm_Initialize()
Dim smsg As String
smsg = "The client " & sTRID & " is not in the datbase." _
& vbCrLf & "Do you want to add them?"
Me.Label1.Caption = smsg
End Sub


"salgud" wrote:

On Thu, 31 Jul 2008 22:31:28 +0100, RB Smissaert wrote:
Thanks for the help.

Does it actually run?

Yes.
Test by putting a Msgbox before
your line where the label gets set.

I tried one after the label got set. If the label isn't set, the MsgBox
can't show it either. It worked.
Did you put it in the right userform?

Only one.

Does the label get set somewhere else in your code?

Nope.
Does it work if you specify a much smaller bit of text?

Tried that, didn't work either.
Any other ideas?


Thanks! This worked great. I had put in "Userform1" because that's the
userform's name is. I guess that's just one of those weird VBA things you
have to know somehow. Don't use the userform's actual name, just use
"userform".

Got it fixed and I learned another of the many anomalies in VBA.