WS
asked on
MS Access - Form - Pass value from one form to multiple forms using condition
Hi,
I have five core table say as tbl1,tbl2,tbl3,tbl4 and tbl5, they all are linked with one table say as tblMain. There are five forms as frm_tbl1,frm_tbl2,frm_tbl3 ,frm_tbl4 and frm_tbl5, in all of these there is a field Sou that need to get value from frm_tblMain. frm_tblMain open when the click event occour in Sou field which open this form, user select the Sou and that value have to pass to previous form. As there are five form is there a way to pass value from one main form to all of this depending upon which form is open. If frm_tble1 is open it should pass to that form ,if other is open to other so on.
Any help?
Thank you.
I have five core table say as tbl1,tbl2,tbl3,tbl4 and tbl5, they all are linked with one table say as tblMain. There are five forms as frm_tbl1,frm_tbl2,frm_tbl3
Any help?
Thank you.
ASKER
But how to pass value using condition, like if the main form is open using form_tbl1 it should pass value to form_tbl1, if it is open using frm_tbl2 then pass value to frm_tbl2 and so on?
WS,
It really depends. Are you opening frm_Main first, then opening the form_tbl1, tbl2, ... , and then trying to pass a value back to frm_Main, which is already open, or is that form closed? It would be helpful to understand the flow of your application better.
It really depends. Are you opening frm_Main first, then opening the form_tbl1, tbl2, ... , and then trying to pass a value back to frm_Main, which is already open, or is that form closed? It would be helpful to understand the flow of your application better.
ASKER
first i will open frm_tbl1,frm_tbl2,.... and then from those forms frm_Main will be open (frm_Main is basically a search form), will select the ID and then ID then should pass back to previous form.
The problem i am having is at this point that while passing value back how the access will know to pass value back to which form,either to frm_Tbl1,frm_tbl2 ...?
The problem i am having is at this point that while passing value back how the access will know to pass value back to which form,either to frm_Tbl1,frm_tbl2 ...?
There are many way to achieve communication between forms:
- Open arguments.
- Referencing the calling form (assuming it is open).
- Equip the calling form with getters and / or setters.
- Raise events.
- Share data trough a file. ect ect ....
- Open arguments.
- Referencing the calling form (assuming it is open).
- Equip the calling form with getters and / or setters.
- Raise events.
- Share data trough a file. ect ect ....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The suggestion all have given i'm working on that but i got one error in my code in implementing this which i am not able to understand, any help?
Error 2447: There is an invalid use of the .(dot) or ! operator or invalid parentheses
Error 2447: There is an invalid use of the .(dot) or ! operator or invalid parentheses
Private Sub Command193_Click()
If Me.txtAddRec = "Cap" Then
Forms!frmAddRecord!Source = Me.txtCap
DoCmd.Close
ElseIf Me.txtAddRec1 = "CapEdit" Then
Forms!frmEditRecord!Source = Me.txtCap1
DoCmd.Close
End If
End Sub
Try Forms!frmAddRecord.Source
re: your post? value?
What is Command193, and what form is it on? where do the values for txtAddRec and txtAddRec1 come from?
What is Command193, and what form is it on? where do the values for txtAddRec and txtAddRec1 come from?
ASKER
@Scoot, not working.
@Dale, Command193 is a button, it is on the frmMain ( the second form that open from frm_tbl1,frm_tbl2,...) txtAddRec and txtAddRec1 are textboxs in frmMain (these are the textboxes that are getting value from previous form,if it is Cap then it's the first form frm_tbl1 else if there is CapEdit it's the frm_tbl2).
@Dale, Command193 is a button, it is on the frmMain ( the second form that open from frm_tbl1,frm_tbl2,...) txtAddRec and txtAddRec1 are textboxs in frmMain (these are the textboxes that are getting value from previous form,if it is Cap then it's the first form frm_tbl1 else if there is CapEdit it's the frm_tbl2).
ASKER
Attach is a sample DB also. frmFirst is the first to open and then click Edit Record where Source field click that go to Search Source and then click on Add Source there the error is.
In Add Record it is working but in Edit Record is the one where ahead it gives error.
Wsm93--1-.accdb
In Add Record it is working but in Edit Record is the one where ahead it gives error.
Wsm93--1-.accdb
Your code works fine IF your form named "Table1" is open. If not, then your code does not work.
I'm not sure what you're trying to accomplish, so it's hard to give suggestions to fix this. Can you provide more details?
I'm not sure what you're trying to accomplish, so it's hard to give suggestions to fix this. Can you provide more details?
ASKER
What i am trying to achieve in this is that when Add Record is click in First form which is named as "frmFirst" , it open Add Record form and then in field Source click on that text box and open the Search Source form name as "frmSourceSearch", there the user select some ID from subform click on Add Source and that ID value should pass to previous form Add Record field Source. (This is working as you can see in the sample DB).
Similarly i want to achieve for Edit Record.Click On First form which is named as "frmFirst" , it open eDIT Record form and then in field Source click on that text box and open the Search Source form name as "frmSourceSearch", there the user select some ID from subform click on Add Source and that ID value should pass to previous form Edit Record field Source. (This is where i am getting this error).
The overall logic behind this is that when the user click add or edit record their form open up either add or edit form and from there with Source field the same form open in both which is frmSourceSearch, user select the Source and then that value should pass back to previous form, if this frmSourceSearch is open then it should pass value to that if it is open from edit then it should pass value to that.
(frmFirst -> Click Add Record -> Table1(form) -> Click Source (field) -> frmSourceSearch (Open) -> Select ID (from Subform) -> Click Add Source -> Pass value back to Add Record form)
(frmFirst -> Click Edit Record -> Table1(form) -> Click Source (field) -> frmSourceSearch (Open) -> Select ID (from Subform) -> Click Add Source -> Pass value back to Edit Record form)
Similarly i want to achieve for Edit Record.Click On First form which is named as "frmFirst" , it open eDIT Record form and then in field Source click on that text box and open the Search Source form name as "frmSourceSearch", there the user select some ID from subform click on Add Source and that ID value should pass to previous form Edit Record field Source. (This is where i am getting this error).
The overall logic behind this is that when the user click add or edit record their form open up either add or edit form and from there with Source field the same form open in both which is frmSourceSearch, user select the Source and then that value should pass back to previous form, if this frmSourceSearch is open then it should pass value to that if it is open from edit then it should pass value to that.
(frmFirst -> Click Add Record -> Table1(form) -> Click Source (field) -> frmSourceSearch (Open) -> Select ID (from Subform) -> Click Add Source -> Pass value back to Add Record form)
(frmFirst -> Click Edit Record -> Table1(form) -> Click Source (field) -> frmSourceSearch (Open) -> Select ID (from Subform) -> Click Add Source -> Pass value back to Edit Record form)
Your Edit Form macro opens a form named "Table1_1", not "Table_1". Could you change that macro to open Table_1 instead of Table1_1?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That's the answer.
Open in new window
You can also reach back to that main form from within Form1 using the Load eventOpen in new window