Synchronizing Two Different Froms Please help.

T

TotallyConfused

Last week I posted regarding synchronizing two different forms. I have 2
main forms with subforms. Form 1 is a doc form with pt listed in a subform.
Form 2 is a pt form with docs listed on the subform. I would like to have
the ability to place my cursor on the doc form's subform for a specific pt.
On a double click have the Pt form open to that specific pt. I tried the
following, in the Doc subform. however, it opens the pt form but with no
data. My PK is PT ID consisting of three letters and 4 number (AAA1234)

Sub Form_DblClick(Cancel As Integer)
DoCmd.Openform "PTForm",,,"PtID =" & Me.Docptlistsubform.txtPTID

End Sub

I also tried: DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT

Nothing!! Do I need to enter some event code on the PTFORM as well?

I have tried different things. Sometimes I get a blank PTFORM or an error
message saying can't find the field PTID referenced in your expression.
Can someone please help me get this right. Thank you in advance for your
help.
 
O

Ofer Cohen

If the code you are using is placed in the sub form, then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT
======================================
If the txtPT field type is text, then you need to add a single quote to the
value

DoCmd.Openform "PTFORM",,,"PTID='" & Me.txtPT & "'"
======================================
If you are trying to open the form from the main form then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.[SubFormControlName].From![txtPT]
======================================
Now, for the main question.
If you want to filter the data that is placed in the sub form of the second
form, all of the above won't work, it will filter only the data on the main
form.

If that the case, please post back and I'll give another way of filtering
the data in the sub form
 
T

TotallyConfused

Thank you for responding. The code that I mentioned below is in Form1 (doc
form) with a sub form of pt's list. I used your first example and I get the
following message "compile error method or data member not found"

Since my txtpt is text I used your second example - I got the same message
as above.

On my Form 1 (Main doc form) there is the subform below of Pts I want to
double click on a patient and then have Form 2 PTFORM open to that specific
pt. I do not want to filter the Patient's subform. Just want the PTFORM to
open to specific patient from Form 1 subform list. I am sure that this can
be accomplished but somehow something minor is missing. I appreciate any
help. Thank you so much

Ofer Cohen said:
If the code you are using is placed in the sub form, then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT
======================================
If the txtPT field type is text, then you need to add a single quote to the
value

DoCmd.Openform "PTFORM",,,"PTID='" & Me.txtPT & "'"
======================================
If you are trying to open the form from the main form then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.[SubFormControlName].From![txtPT]
======================================
Now, for the main question.
If you want to filter the data that is placed in the sub form of the second
form, all of the above won't work, it will filter only the data on the main
form.

If that the case, please post back and I'll give another way of filtering
the data in the sub form

--
Good Luck
BS"D


TotallyConfused said:
Last week I posted regarding synchronizing two different forms. I have 2
main forms with subforms. Form 1 is a doc form with pt listed in a subform.
Form 2 is a pt form with docs listed on the subform. I would like to have
the ability to place my cursor on the doc form's subform for a specific pt.
On a double click have the Pt form open to that specific pt. I tried the
following, in the Doc subform. however, it opens the pt form but with no
data. My PK is PT ID consisting of three letters and 4 number (AAA1234)

Sub Form_DblClick(Cancel As Integer)
DoCmd.Openform "PTForm",,,"PtID =" & Me.Docptlistsubform.txtPTID

End Sub

I also tried: DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT

Nothing!! Do I need to enter some event code on the PTFORM as well?

I have tried different things. Sometimes I get a blank PTFORM or an error
message saying can't find the field PTID referenced in your expression.
Can someone please help me get this right. Thank you in advance for your
help.
 
O

Ofer Cohen

Openning form 2 when the double click is on the sub form of form1, this
should work

DoCmd.Openform "PTFORM",,,"PTID='" & Me.[txtPT] & "'"

Just to make sure that this field is found, open the Immidiate window (press
Ctrl+G) and type

?Forms[Main doc form]![SubFormControlName].Form![txtPT]

Press Enter and see which value returned
Note: Make sure that the main form and the control of the sub form names are
correct.

--
Good Luck
BS"D


TotallyConfused said:
Thank you for responding. The code that I mentioned below is in Form1 (doc
form) with a sub form of pt's list. I used your first example and I get the
following message "compile error method or data member not found"

Since my txtpt is text I used your second example - I got the same message
as above.

On my Form 1 (Main doc form) there is the subform below of Pts I want to
double click on a patient and then have Form 2 PTFORM open to that specific
pt. I do not want to filter the Patient's subform. Just want the PTFORM to
open to specific patient from Form 1 subform list. I am sure that this can
be accomplished but somehow something minor is missing. I appreciate any
help. Thank you so much

Ofer Cohen said:
If the code you are using is placed in the sub form, then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT
======================================
If the txtPT field type is text, then you need to add a single quote to the
value

DoCmd.Openform "PTFORM",,,"PTID='" & Me.txtPT & "'"
======================================
If you are trying to open the form from the main form then use

DoCmd.Openform "PTFORM",,,"PTID=" & Me.[SubFormControlName].From![txtPT]
======================================
Now, for the main question.
If you want to filter the data that is placed in the sub form of the second
form, all of the above won't work, it will filter only the data on the main
form.

If that the case, please post back and I'll give another way of filtering
the data in the sub form

--
Good Luck
BS"D


TotallyConfused said:
Last week I posted regarding synchronizing two different forms. I have 2
main forms with subforms. Form 1 is a doc form with pt listed in a subform.
Form 2 is a pt form with docs listed on the subform. I would like to have
the ability to place my cursor on the doc form's subform for a specific pt.
On a double click have the Pt form open to that specific pt. I tried the
following, in the Doc subform. however, it opens the pt form but with no
data. My PK is PT ID consisting of three letters and 4 number (AAA1234)

Sub Form_DblClick(Cancel As Integer)
DoCmd.Openform "PTForm",,,"PtID =" & Me.Docptlistsubform.txtPTID

End Sub

I also tried: DoCmd.Openform "PTFORM",,,"PTID=" & Me.txtPT

Nothing!! Do I need to enter some event code on the PTFORM as well?

I have tried different things. Sometimes I get a blank PTFORM or an error
message saying can't find the field PTID referenced in your expression.
Can someone please help me get this right. Thank you in advance for your
help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top