Use values from form & subform in stlinkcriteria

R

rwilliams

Hi. I am using Access 2002.

I have a form with an embedded subform. When a user 2x clicks on "ATLAS Ref"
in the subform it opens the Experiment Details form. My problem is that
"ATLAS Ref" may contain data from several batches and I would like to see
only the relevant batch when the field is 2x clicked. I've tried to adjust
the stLinkCriteria to include the "Batch No" however Access tells me it can't
find the Batch No. I think that is because Batch No is on the form, not the
subform. Is there a way to modify the code below so that the criteria
specifies the Batch No contained on the form?

TIA

Private Sub ATLAS_Ref_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Experiment Details"

stLinkCriteria = "[ATLAS Ref]='" & Me![ATLAS Ref] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
 
S

strive4peace

Hello,

try this:

Me.parent.[ATLAS Ref]

you may want to make sure it is filled before using it as a filter...

if isnull(Me.parent.[ATLAS Ref]) then
msgbox "You need to fill out a Batch number",,"Missing data"
me.parent.SetFocus
Me.parent.[ATLAS Ref].SetFocus
exit sub
else
stLinkCriteria = "[ATLAS Ref]='" & Me.parent.[ATLAS Ref] & "'"
end if

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
R

rwilliams

Thanks Crystal

I got it to work following your advice. Many Thanks!!

strive4peace said:
Hello,

try this:

Me.parent.[ATLAS Ref]

you may want to make sure it is filled before using it as a filter...

if isnull(Me.parent.[ATLAS Ref]) then
msgbox "You need to fill out a Batch number",,"Missing data"
me.parent.SetFocus
Me.parent.[ATLAS Ref].SetFocus
exit sub
else
stLinkCriteria = "[ATLAS Ref]='" & Me.parent.[ATLAS Ref] & "'"
end if

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hi. I am using Access 2002.

I have a form with an embedded subform. When a user 2x clicks on "ATLAS Ref"
in the subform it opens the Experiment Details form. My problem is that
"ATLAS Ref" may contain data from several batches and I would like to see
only the relevant batch when the field is 2x clicked. I've tried to adjust
the stLinkCriteria to include the "Batch No" however Access tells me it can't
find the Batch No. I think that is because Batch No is on the form, not the
subform. Is there a way to modify the code below so that the criteria
specifies the Batch No contained on the form?

TIA

Private Sub ATLAS_Ref_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Experiment Details"

stLinkCriteria = "[ATLAS Ref]='" & Me![ATLAS Ref] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
 
S

strive4peace

you're welcome ;) happy to help

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Thanks Crystal

I got it to work following your advice. Many Thanks!!

strive4peace said:
Hello,

try this:

Me.parent.[ATLAS Ref]

you may want to make sure it is filled before using it as a filter...

if isnull(Me.parent.[ATLAS Ref]) then
msgbox "You need to fill out a Batch number",,"Missing data"
me.parent.SetFocus
Me.parent.[ATLAS Ref].SetFocus
exit sub
else
stLinkCriteria = "[ATLAS Ref]='" & Me.parent.[ATLAS Ref] & "'"
end if

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hi. I am using Access 2002.

I have a form with an embedded subform. When a user 2x clicks on "ATLAS Ref"
in the subform it opens the Experiment Details form. My problem is that
"ATLAS Ref" may contain data from several batches and I would like to see
only the relevant batch when the field is 2x clicked. I've tried to adjust
the stLinkCriteria to include the "Batch No" however Access tells me it can't
find the Batch No. I think that is because Batch No is on the form, not the
subform. Is there a way to modify the code below so that the criteria
specifies the Batch No contained on the form?

TIA

Private Sub ATLAS_Ref_DblClick(Cancel As Integer)

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Experiment Details"

stLinkCriteria = "[ATLAS Ref]='" & Me![ATLAS Ref] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
 

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