Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Getting text string into userform

I'm working on a program that needs a text string to show in the label in a
userform. I got some help with it, but the code he gave me doesn't work,
and I've never seen it done this way before, so I can't figure out what is
wrong. This is the code I was given, which is in the userform. I'm not even
sure that's where it's supposed to go.

Sub UserForm1_Initialize()
Dim sMsg As String
sMsg = "The client " & sTRID & " is not in the datbase." _
& vbCrLf & "Do you want to add them?"

Label1.Text = sMsg <----- Method or data member not found

End Sub

I'm getting a Method or data member not found on the ".Text" portion. Does
anyone know what's wrong? The variable "sTRID" is publicly declared in the
module.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Getting text string into userform

Try instead Label1.Caption

RBS


"salgud" wrote in message
.. .
I'm working on a program that needs a text string to show in the label in
a
userform. I got some help with it, but the code he gave me doesn't work,
and I've never seen it done this way before, so I can't figure out what is
wrong. This is the code I was given, which is in the userform. I'm not
even
sure that's where it's supposed to go.

Sub UserForm1_Initialize()
Dim sMsg As String
sMsg = "The client " & sTRID & " is not in the datbase." _
& vbCrLf & "Do you want to add them?"

Label1.Text = sMsg <----- Method or data member not found

End Sub

I'm getting a Method or data member not found on the ".Text" portion. Does
anyone know what's wrong? The variable "sTRID" is publicly declared in the
module.

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Getting text string into userform

On Thu, 31 Jul 2008 21:55:44 +0100, RB Smissaert wrote:

Try instead Label1.Caption

RBS

Thsnks for your reply. That's a step in the right direction. It compiles
and runs now. But I'm still not getting the text string as the label in the
userform. It just shows "Label1". I want it to show that text with the
string variable "sTRID" in it. Any suggestions?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Getting text string into userform

Does it actually run? Test by putting a Msgbox before
your line where the label gets set.
Did you put it in the right userform?
Does the label get set somewhere else in your code?
Does it work if you specify a much smaller bit of text?

RBS

"salgud" wrote in message
...
On Thu, 31 Jul 2008 21:55:44 +0100, RB Smissaert wrote:

Try instead Label1.Caption

RBS

Thsnks for your reply. That's a step in the right direction. It compiles
and runs now. But I'm still not getting the text string as the label in
the
userform. It just shows "Label1". I want it to show that text with the
string variable "sTRID" in it. Any suggestions?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Getting text string into userform

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?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Getting text string into userform

Can't think of much else now. It works fine with me.

If the label isn't set, the MsgBox can't show it either. It worked.


Not sure what you are saying here. Did you see the message box popping up?

Are there any non-default properties of that label?
Try removing that label and try with a new one?
How about taking Label1 out of the Caption property box?


RBS


"salgud" wrote in message
...
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?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Getting text string into userform

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?

  #8   Report Post  
Posted to microsoft.public.excel.programming
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.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Getting text string into userform

On Thu, 31 Jul 2008 23:31:24 +0100, RB Smissaert wrote:

Can't think of much else now. It works fine with me.

If the label isn't set, the MsgBox can't show it either. It worked.


Not sure what you are saying here. Did you see the message box popping up?

Are there any non-default properties of that label?
Try removing that label and try with a new one?
How about taking Label1 out of the Caption property box?


RBS


"salgud" wrote in message
...
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 for the help, got it fixed. If curious, see below.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text string to Numeric string Manikandan[_2_] Excel Discussion (Misc queries) 2 March 12th 09 08:55 AM
userform incorporates string data salgud Excel Programming 6 July 31st 08 08:51 PM
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
Assigning the name of a userform/control to a changing string Brad Patterson Excel Programming 2 July 16th 03 11:00 PM


All times are GMT +1. The time now is 11:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"