LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Problem using UserForm in Macro

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



 
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
Userform Import problem Hedghog Excel Discussion (Misc queries) 0 June 2nd 10 01:57 PM
Userform problem? law Excel Discussion (Misc queries) 0 December 3rd 07 07:54 PM
userform problem TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 August 10th 06 04:43 AM
printen userform problem Pierre via OfficeKB.com Excel Worksheet Functions 0 January 3rd 06 04:45 PM
newbie userform problem Kevin Excel Programming 1 August 5th 03 12:25 AM


All times are GMT +1. The time now is 09:40 PM.

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

About Us

"It's about Microsoft Excel"