That' s all possible.
1. You can add a module where you put procedures into and call them from your form code. So you can avoid pasting code in all the forms. Just add a procedure with your code and when you make changes just correct this procedure.
2. You can do with your TextBox values whatever you want.
Alex.
You can't just put that code in a public module and expect it to work!
The textboxes & Lables & Comboboxes MUST be passed in as arguments to the sub !
Let me try to understand exactley what you are trying to do, are you saying that you have the same controls as in the sub on several forms, and therefore want to be able to use the same code to set all the controls ???
If so then you need to do something like
VB Code:
Public Sub longlargepvisibility(txtlong as textbox,txtlarg as textbox,cbo1 as combobox lbl1 as label) 'e.t.c
'Pass in all your controls to the sub and then set them
in fact all the forms are not shown at the same moment but i use the same type of information on many forms so i try to use the same control for the same information
don't work the call method ask for an argument, never used this before so i'am a little locked here is the call property i use and the title of the sub
VB Code:
Call longlargepvisibility
Sub longlargepvisibility(longueur As TextBox, largeur As TextBox, epaisseur As TextBox, combounite As ComboBox, Label4 As Label, Label5 As Label, Label6 As Label, pertes As TextBox)
you need to pass the txtboxes e.t.c into it, if you put on open bracket "(" after longlargepvisibility you will get a list of arguements that the sub expects.
so it shold look something like
VB Code:
Call longlargepvisibility(longuer,larger, e.t.c )
Now on every form you can just use the Call longlargepvisibility sub and pass in the controls !
Call longlargepvisibility(longueur As TextBox, largeur As TextBox, epaisseur As TextBox, combounite As ComboBox, Label4 As Label, Label5 As Label, Label6 As Label, pertes As TextBox)
this tells me that syntax is wrong
i think it is witing for some kind of value but don't know what
Just so you know i have had that demo working in front of me, in VBA, so there is no doubt that it works. If you could tell me where you are getting this error in the code maybe i could help you more !!!
Ah, I see what i have sent you write learner is a demo, and was intended to give you an EXAMPLE of how To make a Public Sub to Change all txtboxes work !
TO RUN THE DEMO
what you need to do is open a brand new project, seperate from what you are doing and import the 3 forms & the module i have sent you into it.
Then try running frmMenu, this demo should show you how you need to change your code to work correctly!
USING THE MODULE IN YOUR PROJECT !!!
If you want you can just use the Module1.bas that i sent you also, on its own. First add it YOUR project
To call the sub inside it though you shold use the following syntax
Well, i really don't understand why thats happening, I have the form in front of me and it is working Fine, unless Microsoft have made some changes in WORD 2003 to Types then i am stuck.
BUT Trust me this does work in WORD 2002, as i have it in front of me now working!.
Does anybody else out their have any idea of why this sub is working for me but not for writelearner ???
apparently Excel has two lots of Type Library's for Textbox's, ComboBoxes and the like so when you are declaring a Textbox for instance you need to make sure you declare the right one.
instead of
Dim txtbox1 as textbox
put
dim txtbox1 as msforms.textbox
in terms of the problem with the sub all i had to do was change:
VB Code:
Public Sub longlargepvisibility(longueur As TextBox, Largeur As TextBox, epaisseur As TextBox, ComboUnite As ComboBox, Label4 As Label, Label5 As Label, Label6 As Label, pertes As TextBox)
to
VB Code:
Public Sub longlargepvisibility(longueur As MSForms.TextBox, Largeur As MSForms.TextBox, epaisseur As MSForms.TextBox, ComboUnite As MSForms.ComboBox, Label4 As MSForms.Label, Label5 As MSForms.Label, Label6 As MSForms.Label, pertes As MSForms.TextBox)
Anyway i have altered my Module to take this into account. If you download this module and use it with the 3 forms i sent it should work now!
Last edited by NeedSomeAnswers; Sep 23rd, 2004 at 08:48 AM.