You have your commands the wrong way round. Something like:
Public Sub test()
With UserForm1
.TextBox1.Text = "hello"
.Show
End With
End Sub
would work. Problem is your showing the form, execution jumps to it (even
if it has no code) and only returns to the line setting the text when it is
closed (assuming it's a modal form).
--
Regards,
Bill Lunney
www.billlunney.com
"Terence" wrote in message
...
Hi,
I am writing a macro with a button on the worksheet. When
the button is clicked, the userform pops up and the data
of the recordset is displayed on the textbox of the form.
e.g.
Private Sub cmdButton_Click()
:
:
frmTest.Show
frmTest.txtbox1.Value = rst.Fields("testing")
End Sub
However, the screen pops up but the textbox remains empty.
Then I close the form and press the button again, the
screen pops up but this time the value is shown on the
textbox. Does anyone knows why?
Thanks a lot.
Terence