Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default filling userform textboxes

Hi expert,

i user userform1 to retreive data from an excel sheet . The data should then
be visible in textboxes on userform1 that have no sourcecontrol.
My questions:

1. is it possible to write vba code to fill the textbox from the datasheet ?
I think yes, something like: txt_myname.text = sheets("datasheet").
range("A3").value
is this the correct way ?

2. is it possible to make a seperate module with vba code to fill textboxes
on userform1
I think yes but don't know how...can you help

3. is it possible to use vba code in a different userform2 to fill textboxes
in userform1 ?
I think no, but can you help if it is possible ?

Thanks for looking at my problem.
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200510/1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default filling userform textboxes

The answer to all three question is yes.

1. exactly

2. but why would you want to; you can do the same with the code in the
userform module. If you choose that path, you would call code in this
module from the code in the Userform module.
You would need to fully qualify your references like
Userform1.Txt_Myname.txt = . . .

3. As long as userform1 is loaded (doesn't necessarily have to be visible),
then any code can set the value of a control in userform1 including code in
userform2. You just have to use the fully qualified reference as shown
above.

--
Regards,
Tom Ogilvy


"Pierre via OfficeKB.com" <u13950@uwe wrote in message
news:55d452d4e06d4@uwe...
Hi expert,

i user userform1 to retreive data from an excel sheet . The data should

then
be visible in textboxes on userform1 that have no sourcecontrol.
My questions:

1. is it possible to write vba code to fill the textbox from the datasheet

?
I think yes, something like: txt_myname.text = sheets("datasheet").
range("A3").value
is this the correct way ?

2. is it possible to make a seperate module with vba code to fill

textboxes
on userform1
I think yes but don't know how...can you help

3. is it possible to use vba code in a different userform2 to fill

textboxes
in userform1 ?
I think no, but can you help if it is possible ?

Thanks for looking at my problem.
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200510/1



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default filling userform textboxes

A slight qualification.

It is not unusual to have initialization code in a general module. This is
a matter of style. (the other choice would be the initialize event for the
userform).

Sub MycodeInAGeneralModule()
Dim rng as Range
set rng = Worksheets("Datasheets").Range("A3")
With Userform1
.txt_myname.txt = rng.value
.txt_myaddress.txt = rng.offset(1,0).value
.txt_mycity.txt = rng.offset(2,0).value
.show
End With
End Sub

the alternative would be
Sub MycodeInAGeneralModule()
Userform1.Show
End With

in the userform module

Private Sub Userform_Intialize()
Dim rng as Range
set rng = Worksheets("Datasheets").Range("A3")
me.txt_myname.txt = rng.value
me.txt_myaddress.txt = rng.offset(1,0).value
me.txt_mycity.txt = rng.offset(2,0).value
End Sub

--
Regards,
Tom Ogilvy


"Pierre via OfficeKB.com" <u13950@uwe wrote in message
news:55d452d4e06d4@uwe...
Hi expert,

i user userform1 to retreive data from an excel sheet . The data should

then
be visible in textboxes on userform1 that have no sourcecontrol.
My questions:

1. is it possible to write vba code to fill the textbox from the datasheet

?
I think yes, something like: txt_myname.text = sheets("datasheet").
range("A3").value
is this the correct way ?

2. is it possible to make a seperate module with vba code to fill

textboxes
on userform1
I think yes but don't know how...can you help

3. is it possible to use vba code in a different userform2 to fill

textboxes
in userform1 ?
I think no, but can you help if it is possible ?

Thanks for looking at my problem.
Pierre


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200510/1



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default filling userform textboxes

Thanks Tom,

you're the greatest !!!!
option 2 works perfectly for me !!!
I had forgotten to fully mention the path !
thanks again !
Pierre

Tom Ogilvy wrote:
The answer to all three question is yes.

1. exactly

2. but why would you want to; you can do the same with the code in the
userform module. If you choose that path, you would call code in this
module from the code in the Userform module.
You would need to fully qualify your references like
Userform1.Txt_Myname.txt = . . .

3. As long as userform1 is loaded (doesn't necessarily have to be visible),
then any code can set the value of a control in userform1 including code in
userform2. You just have to use the fully qualified reference as shown
above.

Hi expert,

[quoted text clipped - 17 lines]
Thanks for looking at my problem.
Pierre



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200510/1
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
UserForm TextBoxes Rob Excel Discussion (Misc queries) 2 August 6th 05 03:07 AM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Filling Cells from Textboxes trini Excel Programming 3 February 19th 05 09:37 PM
userform & textboxes beginner Excel Programming 3 July 27th 04 10:56 AM
searching for a combobox.value and filling in textboxes from results GregJG[_18_] Excel Programming 3 July 8th 04 12:41 PM


All times are GMT +1. The time now is 01:59 AM.

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"