Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default referencing controls in userform from a different workbook

I want to be able to call up the same subform from a number of different
forms in different workbooks.
I have "customers.xls" with a macro to show a form that lists all the
customer names.
The user can be using various forms in different workbooks that need the
exact customer name. So with Application.Run and refernce to the workbook and
its macro I can open the form.
When the user double-clicks an item in the listbox the value should get put
into a textbox on the form that called the subform.
I'm missing the final stage - how do I reference the target textbox so that
the data will go where I want it?

--
WinXP - Office2003 (Italian)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default referencing controls in userform from a different workbook

Reverse the path you used to get to the list box that is clicked.

Workbooks("Customers.xls").<userformname.<control name =
<listboxname.value

The form needs to be in show mode when you do it or the control cannot be
accessed.


"David Macdonald" wrote in
message ...
I want to be able to call up the same subform from a number of different
forms in different workbooks.
I have "customers.xls" with a macro to show a form that lists all the
customer names.
The user can be using various forms in different workbooks that need the
exact customer name. So with Application.Run and refernce to the workbook
and
its macro I can open the form.
When the user double-clicks an item in the listbox the value should get
put
into a textbox on the form that called the subform.
I'm missing the final stage - how do I reference the target textbox so
that
the data will go where I want it?

--
WinXP - Office2003 (Italian)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default referencing controls in userform from a different workbook

Thanks for the response but I'm still unable to get it to work. I have things
set up like this:
workbook: Customers.xls
userform: FindCustomerForm
control: CustomerListbox

The first workbook I want to have opening the form and getting info from it
is "Orders":
workbook: Orders.xls
userform: NewOrderForm
control: CustomerName
Double-clicking in the CustomerName textbox opens the FindCustomerForm. I
find the right customer and double-click the listbox item.
At that point FindCustomerForm should transfer the value to CustomerName on
NewOrderForm then unload itself.

If the two forms are in the same workbook I can get this to work perfectly,
using a public string "ThisControl" to retain the name of the control that
called the customer list for example:
Private Sub CustomerName_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ThisControl = "CustomerName"
FindCustomerForm.Show
End Sub

and

Private Sub CustomerListbox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
NewOrderForm.Controls(ThisControl).Value = CustomerListbox.Value
ThisControl = ""
Unload Me
End Sub


My problem is that I want to call FindCustomerForm from Complaints.xls,
Shipments.xls, and ChristmasGreetings.xls too.

So how do I construct the general purpose string (including network path)
that will get the customer name to whatever control called it?
Do I need to put "Public ThisControl As String" in both workbooks?


--
WinXP - Office2003 (Italian)


"JLGWhiz" wrote:

Reverse the path you used to get to the list box that is clicked.

Workbooks("Customers.xls").<userformname.<control name =
<listboxname.value

The form needs to be in show mode when you do it or the control cannot be
accessed.


"David Macdonald" wrote in
message ...
I want to be able to call up the same subform from a number of different
forms in different workbooks.
I have "customers.xls" with a macro to show a form that lists all the
customer names.
The user can be using various forms in different workbooks that need the
exact customer name. So with Application.Run and refernce to the workbook
and
its macro I can open the form.
When the user double-clicks an item in the listbox the value should get
put
into a textbox on the form that called the subform.
I'm missing the final stage - how do I reference the target textbox so
that
the data will go where I want it?

--
WinXP - Office2003 (Italian)



.

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
Referencing Userform Controls JeremyJ Excel Programming 0 January 10th 09 12:43 AM
Referencing Controls Using Variables Teodomiro[_3_] Excel Programming 4 April 28th 06 06:21 PM
referencing forms controls AlbertYWang Excel Programming 3 February 1st 06 01:59 PM
Referencing worksheet controls Frederick Chow Excel Programming 2 December 12th 05 05:42 PM
Referencing to controls on a worksheet John Nikolopoulos Excel Programming 3 September 10th 03 10:08 AM


All times are GMT +1. The time now is 10:31 AM.

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"