jaisonshereen
asked on
How to get the value of access combo box from one form to another form?
How to get the value of access combo box from one form to another form?
they
button1_click
if not isnull(forms.form1.combobo x) then
me.controlName = forms.form1.combobox
Else
Exit Sub
End If
End Sub
button1_click
if not isnull(forms.form1.combobo
me.controlName = forms.form1.combobox
Else
Exit Sub
End If
End Sub
ASKER
why we are using :
if not isnull(forms.form1.combobo x) then
??
if not isnull(forms.form1.combobo
??
so that you don't get an error if the is no value in the combo box. Just an optional error control measure
ASKER
when i type
forms. i am getting options to select ..
application,count,item,par ent
i dont need to select none of this ..right?
i can type forms.form1.comboboxname=" value"
right?
forms. i am getting options to select ..
application,count,item,par
i dont need to select none of this ..right?
i can type forms.form1.comboboxname="
right?
ASKER
Not working ..
438 , object doesn't support this property or method ...
i am using a subform so i need to put the parent form name also???
438 , object doesn't support this property or method ...
i am using a subform so i need to put the parent form name also???
just type forms.Form1.combobo1=me.co ntrolname
form1 is the name of the form1
combox1 is the name of the combobox on form1 that contain the data you want to import
control name is the name of the controm on the same form as the button that you want to input the data
I note that form1 has to be open for this to work
also its best you put the combobox in form2 as an unbounded combobox the you code will be
button1_click
if not isnull(Me.combobox) then
Me.controlName = Me.combobox
Else
Exit Sub
End If
End Sub
form1 is the name of the form1
combox1 is the name of the combobox on form1 that contain the data you want to import
control name is the name of the controm on the same form as the button that you want to input the data
I note that form1 has to be open for this to work
also its best you put the combobox in form2 as an unbounded combobox the you code will be
button1_click
if not isnull(Me.combobox) then
Me.controlName = Me.combobox
Else
Exit Sub
End If
End Sub
ASKER
nope!!
is this what you expected?
is this what you expected?
me.controlbox=me.combobox_name
if(Forms.subform1.combobox_name="value"
then
do something
Else
do something
End if
If you are using a subform the syntax is
Forms.FormName.SubformName .Form.Cont rolName
Forms.FormName.SubformName
ASKER
oops
control name is the name of the controm on the same form as the button that you want to input the data
i am not supposed to change the design..of the form..!!
So i cannot make a controlname
control name is the name of the controm on the same form as the button that you want to input the data
i am not supposed to change the design..of the form..!!
So i cannot make a controlname
You can do virtually anything. But some are more difficult than others. I like to stick to the easy option
Your code should look like the one below. Remember Me means the current form. If you are refering to another form or subform then you have to write the complete reference to that object
Your code should look like the one below. Remember Me means the current form. If you are refering to another form or subform then you have to write the complete reference to that object
Private Sub Command61_Click()
If Not IsNull(Me.try) Then
Me.re = Me.try
Else
Exit Sub
End If
End Sub
the code I have just send put the value selected in the combobox named try in a textbox named re
If the is nothing in try nothing happens
If the is nothing in try nothing happens
ASKER
nope still not working!!
ASKER
ok let me check
1) send a copy of your code
2) explain the setup of your two forms. What are they called, what is the name of the subform, where are the combobox, textbox and button (on which form or subform.
3) or better still just send a copy of your db
2) explain the setup of your two forms. What are they called, what is the name of the subform, where are the combobox, textbox and button (on which form or subform.
3) or better still just send a copy of your db
ASKER
This is what i did its still not working;
Private Sub Command61_Click()
Dim re as textbox
Me.re = Me.Combobox1
if(Me.re="value")
then
do something
Else
do something
End if
End Sub
ASKER
This is the form!
Form.JPG
Form.JPG
ASKER
I am trying to get the value of year ...using the button below i rounded ...
i went to the click event of the button and i am trying to get the value ,,,of the year ...
i went to the click event of the button and i am trying to get the value ,,,of the year ...
ASKER
search is another form... and one which i click the botton is another form!
you don't need to dim re as textbox
when you type me. you should get an option list. Start typing the name of your textbox (do you know the name of your textbox?) and it will come up in the option list
I notice you have copied the name of my button Command_61. It would be a strang coincidence if your button has the same name.
To use a button onclick open the form in design view. double click on the button to open the procedure dialog. From the drop down in the onclick field in the event tab click event procedure. Then click on the like box at the right of the field. Then write your code between Private Sub ButtonName_Click() and End Sub
when you type me. you should get an option list. Start typing the name of your textbox (do you know the name of your textbox?) and it will come up in the option list
I notice you have copied the name of my button Command_61. It would be a strang coincidence if your button has the same name.
To use a button onclick open the form in design view. double click on the button to open the procedure dialog. From the drop down in the onclick field in the event tab click event procedure. Then click on the like box at the right of the field. Then write your code between Private Sub ButtonName_Click() and End Sub
ASKER
This is the click event.... here i need to get value!
Private Sub Cmd_POSBrief_Click()
On Error GoTo Err_Cmd_POSBrief_Click
Call Project1.Form_T_F900_GeneralSearch.CheckForNullSearch
FixSearchCriteria
DoCmd.OpenReport "T_043_POSBriefReport", acViewPreview
Exit_Cmd_POSBrief_Click:
Exit Sub
Err_Cmd_POSBrief_Click:
ApplicationError Err.Number, Err.Description, "Form_T_F130_ViewRollupPromotions\Cmd_POSBrief_Click"
Resume Exit_Cmd_POSBrief_Click
End Sub
ASKER
Like this??
Private Sub Cmd_POSBrief_Click()
On Error GoTo Err_Cmd_POSBrief_Click
Call Project1.Form_T_F900_GeneralSearch.CheckForNullSearch
FixSearchCriteria
me.textboxname=me.comboboxname
if (me.textboxname-"2007") then
DoCmd.OpenReport "T_043_POSBriefReport", acViewPreview
Else
DoCmd.OpenReport "T_043_POSBriefReport2", acViewPreview
End If
Exit_Cmd_POSBrief_Click:
Exit Sub
Err_Cmd_POSBrief_Click:
ApplicationError Err.Number, Err.Description, "Form_T_F130_ViewRollupPromotions\Cmd_POSBrief_Click"
Resume Exit_Cmd_POSBrief_Click
End Sub
looks like both the search form and the form with the botton are search form of another form
And its not clear where you want to insert the year value. If you want to open a report then that's a totally different code
And its not clear where you want to insert the year value. If you want to open a report then that's a totally different code
ASKER
Please note "Form_T_F130_ViewRollupPro motions" this is current form !!
ASKER
Actually i need to open two type of report according to the year value ...!
I form with combobox name is different .. that is why i told it is a subform
I form with combobox name is different .. that is why i told it is a subform
You are not getting anything because you are typing comboboxname, textboxname ect..
You have to use the actual names of these objects. To find their name go to their property dialog box. Click the other tab. Their names are in the first row. You can change the name if you want
You have to use the actual names of these objects. To find their name go to their property dialog box. Click the other tab. Their names are in the first row. You can change the name if you want
ASKER
:-)
T_F900_GeneralSearch is the form which having combobox
Combo_Year is the combobox name in the T_F900_GeneralSearch
Form_T_F130_ViewRollupProm otions is the form having the button
And above code which i given is the click event of the button. Cmd_POSBrief_Click()
T_F900_GeneralSearch is the form which having combobox
Combo_Year is the combobox name in the T_F900_GeneralSearch
Form_T_F130_ViewRollupProm
And above code which i given is the click event of the button. Cmd_POSBrief_Click()
ASKER
This is what i did it as per your request ..its not working!
Private Sub Cmd_POSBrief_Click()
On Error GoTo Err_Cmd_POSBrief_Click
Call Project1.Form_T_F900_GeneralSearch.CheckForNullSearch
FixSearchCriteria
if (Forms.Form_T_F130_ViewRollupPromotions.Form_T_F900_GeneralSearch.Form.Combo_Year=2007) then
DoCmd.OpenReport "T_043_POSBriefReport", acViewPreview
Else
DoCmd.OpenReport "T_043_POSBriefReport2", acViewPreview
End If
Exit_Cmd_POSBrief_Click:
Exit Sub
Err_Cmd_POSBrief_Click:
ApplicationError Err.Number, Err.Description, "Form_T_F130_ViewRollupPromotions\Cmd_POSBrief_Click"
Resume Exit_Cmd_POSBrief_Click
End Sub
That's to open the form
docmd.OpenReport ("reportname",acViewPrevie w,,year = chr(34) & forms.formname.subformsear chname.com boname & chr(34))
If you send a copy of the db remove db I can fix it for you. Looks like you are getting mixed up with these long name
docmd.OpenReport ("reportname",acViewPrevie
If you send a copy of the db remove db I can fix it for you. Looks like you are getting mixed up with these long name
ASKER
docmd.OpenReport ("reportname",acViewPrevie w,,year = chr(34) & forms.formname.subformsear chname.com boname & chr(34))
Can you explain this?
Can you explain this?
ASKER
how will this a solution for above?
T_F900_GeneralSearch is the form which having combobox
Combo_Year is the combobox name in the T_F900_GeneralSearch
Form_T_F130_ViewRollupProm otions is the form having the button
And above code which i given is the click event of the button. Cmd_POSBrief_Click()
ok try the code below and tell me what happens. That is just a trial
Combo_Year is the combobox name in the T_F900_GeneralSearch
Form_T_F130_ViewRollupProm
And above code which i given is the click event of the button. Cmd_POSBrief_Click()
ok try the code below and tell me what happens. That is just a trial
Private Sub Cmd_POSBrief_Click()
dim str as string
str = forms.T_F900_GeneralSearch.Combo_Year
msgbox (This report is for the year "str")
End Sub
sorry line 7 should be
msgbox ("This report is for year" & str)
msgbox ("This report is for year" & str)
ASKER
Nope its not working..its saying 438 , object doesn't support this property or method ...
whenever i type
Forms and a [DOT] after that ..
i am getting options to select ..
application,count,item,par ent
i am NOT getting T_F900_GeneralSearch
will it be right?
whenever i type
Forms and a [DOT] after that ..
i am getting options to select ..
application,count,item,par
i am NOT getting T_F900_GeneralSearch
will it be right?
From the picture you send it looks like Form_T_F130_ViewRollupProm otions is your main form
then you have 5 subforms on it and the button is on one of the subform, not on the Form_T_F130_ViewRollupProm otions as you mentioned. The code will never work unless you are precise.
I think that I know have a better understanding of your form setup. So I will retry the message box code
then you have 5 subforms on it and the button is on one of the subform, not on the Form_T_F130_ViewRollupProm
I think that I know have a better understanding of your form setup. So I will retry the message box code
Private Sub Cmd_POSBrief_Click()
dim str as string
str = Forms.Form_T_F130_ViewRollupPromotions.Form_T_F900_GeneralSearch.Form.Combo_Year
msgbox (This report is for the year "str")
End Sub
Opps forgot the " " again
Private Sub Cmd_POSBrief_Click()
dim str as string
str = Forms.Form_T_F130_ViewRollupPromotions.Form_T_F900_GeneralSearch.Form.Combo_Year
msgbox ("This report is for the year" & str)
End Sub
ASKER
its not working
in the form
Form_T_F900_GeneralSearch
me.Combo_Year..i can get the value!!
But not in Form_T_F130_ViewRollupProm otions
:-(
in the form
Form_T_F900_GeneralSearch
me.Combo_Year..i can get the value!!
But not in Form_T_F130_ViewRollupProm
:-(
send a copy of your latest code
What do you mean a get the value Did you try using the msgbox to check if the value is being picked up
ASKER
aha......!!
there was another subform for Form_T_F130_ViewRollupProm otions called T_F900_GeneralSearch_SubFo rm
where this Form_T_F900_GeneralSearch is located ...he he!
there was another subform for Form_T_F130_ViewRollupProm
where this Form_T_F900_GeneralSearch is located ...he he!
ASKER
Forms.Form_T_F130_ViewRoll upPromotio ns.Form_T_ F900_Gener alSearch_S ubForm.For m_T_F900_G eneralSear ch.Form.Co mbo_Year
this will work i guess!!
this will work i guess!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
nope....
This is my present code still not JOY.
I thing to note:
I cannot see the subform ...... Form_T_F900_GeneralSearch_ SubForm any of the listing in Access Forms
I can see only in the window of T_F130_ViewRollupPromotion s... when i click on the search box..box will highlights..
then if i got to properties ..others i can see the name as "Form_T_F900_GeneralSearch _SubForm"
This is my present code still not JOY.
I thing to note:
I cannot see the subform ...... Form_T_F900_GeneralSearch_
I can see only in the window of T_F130_ViewRollupPromotion
then if i got to properties ..others i can see the name as "Form_T_F900_GeneralSearch
Private Sub Cmd_POSBrief_Click()
On Error GoTo Err_Cmd_POSBrief_Click
Call Project1.Form_T_F900_GeneralSearch.CheckForNullSearch
FixSearchCriteria
if (Forms.Form_T_F130_ViewRollupPromotions.Form_T_F900_GeneralSearch_SubForm.Form_T_F900_GeneralSearch.Form.Combo_Year=2007) then
DoCmd.OpenReport "T_043_POSBriefReport", acViewPreview
Else
DoCmd.OpenReport "T_043_POSBriefReport2", acViewPreview
End If
Exit_Cmd_POSBrief_Click:
Exit Sub
Err_Cmd_POSBrief_Click:
ApplicationError Err.Number, Err.Description, "Form_T_F130_ViewRollupPromotions\Cmd_POSBrief_Click"
Resume Exit_Cmd_POSBrief_Click
End Sub
ASKER
so i guess i need to use (exclamation) some where in between !!
Delete your code and insert the one below and let me know what happens
Private Sub Cmd_POSBrief_Click()
dim str as string
dim str as string
Str =
Forms!Form_T_F130_ViewRollupPromotions.Form_T_F900_GeneralSearch_SubForm.Form!Combo_Year
msgbox ("This report is for the year" & str)
End Sub
You can get away with the dots and exclamation but I am sure you don't have Form_T_F900_GeneralSearch_ SubForm inside itself which is what your code is saying
but try the little test using the msgbox first once this work we can move on to the report. NO report code until we are sure that we have the right reference for the combo box
ASKER
i am getting till here ..
when i typed
me and [DOT] ..i am getting Form_T_F900_GeneralSearch_ SubForm automatically
so now
me.Form_T_F900_GeneralSear ch_SubForm .Form.
then what should i follow!???
when i typed
me and [DOT] ..i am getting Form_T_F900_GeneralSearch_
so now
me.Form_T_F900_GeneralSear
then what should i follow!???
ASKER
yeeeeeeeeeeeeeeessssssssss ssssssssss
its working
me.Form_T_F900_GeneralSear ch_SubForm .Form.Comb o_Year
worked ...he he !! :-D
Thanks a lots yaar!!
its working
me.Form_T_F900_GeneralSear
worked ...he he !! :-D
Thanks a lots yaar!!
me.Form_T_F900_GeneralSear ch_SubForm .Form.Comb o_Year
ok settle down. What is working. The whole thing or just the message box
ASKER
ok whole thing is working!! thanks!
ASKER
Thanks a ton!
ASKER
where in form2 ...there is a button1 ...on the click event of the button i can write some thing like..
button1_click()
if (form1 combobox value is 3)
then
do this
end if