PDA

View Full Version : Displaying a text box within a form pre-populated with a variable's text content



Asterix
02-27-2008, 07:37 AM
Sorry, this one must be easy and therefore a repost but I'm struggling to find anywhere that explains it in simpleton terms.

1) I'm using the following text to load and display a user defined form ("body_text_form") in the hope that the text displayed in the udf's text box will be that already assigned to the calling macro variable "body_text"



Load body_text_form
MsgBox body_text_form.TextboxText = body_text
body_text_form.Show


Obviously that doesn't work, though I don't know why. I can't use an input box (easily) as the body_text value can go over multiple lines. How should the code read please?

2) [I could start a new thread but it's related]...assuming the user is happy with what's originally displayed OR what they've amended it to, they'd then press an "OK" button that I've tagged on to the bottom of the udf...2nd question is, how do I assign a "close form and continue macro" action to that button.

mikerickson
02-27-2008, 08:06 AM
1)With body_text_form
.TextBox.Text = body_text
.Show
End With
2)
Private Sub butClose_Click()
Call SaveUFInputsToSpreadhseet
Unload Me
End Sub

Asterix
02-27-2008, 09:01 AM
Thanks Mike, haven't got to (2) yet because when I insert (1) in the macro I get a "Compile error: Method or data member not found".

Have also tried inserting "Load body_text_form" before your with statement, but to no avail.

mikerickson
02-27-2008, 11:39 AM
When I first posted, I wondered if there was a typo or if the textbox was actually named TextBox1.

Also, is body_text_form the name of the user form?

And, is this code in the same workbook as the userform body_text_form?

Asterix
02-27-2008, 01:58 PM
sorry, thought I'd replied to this earlier. I'm sure your code was correct (don't have access to it here), I fixed the problems I'd caused my amending the form properties.

I.e. "solved", thanks