Open and goto same ID on subform

  • Thread starter Bradley C. Hammerstrom
  • Start date
B

Bradley C. Hammerstrom

Access2000

May not be possible . . .
User is viewing records on Form1 and finds one that has a photo he wants to
view using another form.
So user clicks cmdOpenForm2 with OpenArgs set to Form1's PhotoID.
Form2 opens, but PhotoID is on the Subform, not the Mainform of Form2.

Q: How can OpenArgs (or similar) be used to go to a matching record on a
subform?

Brad H.
 
I

Iryna Roy

Bradley C. Hammerstrom said:
Access2000

May not be possible . . .
User is viewing records on Form1 and finds one that has a photo he wants to
view using another form.
So user clicks cmdOpenForm2 with OpenArgs set to Form1's PhotoID.
Form2 opens, but PhotoID is on the Subform, not the Mainform of Form2.

Q: How can OpenArgs (or similar) be used to go to a matching record on a
subform?

Brad H.
Why OpenArgs ???????
Press F1 on Docmd.OpenForm .... and check the example

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"

stLinkCriteria = "[PhotoID]=" & Me![PhotoID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Regards,
Iryna
 
B

Bradley C. Hammerstrom

Iryna,

I'll try this, but let me repeat that Form2 has no PhotoID field. PhotoID is
on Form2Subform, not Form2.

Brad H.

Iryna Roy said:
Access2000

May not be possible . . .
User is viewing records on Form1 and finds one that has a photo he wants to
view using another form.
So user clicks cmdOpenForm2 with OpenArgs set to Form1's PhotoID.
Form2 opens, but PhotoID is on the Subform, not the Mainform of Form2.

Q: How can OpenArgs (or similar) be used to go to a matching record on a
subform?

Brad H.
Why OpenArgs ???????
Press F1 on Docmd.OpenForm .... and check the example

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"

stLinkCriteria = "[PhotoID]=" & Me![PhotoID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Regards,
Iryna
 
B

Bradley C. Hammerstrom

Iryna,

As you suggested, I tried the following with reference to the subform, but
no good.

Dim strFormName As String
Dim strLinkCriteria As String

'Open the Main form and go to same photo on the subform
strFormName = "frmMain"
strLinkCriteria = "Forms!frmMain.frmMainSub1.Form![PhotoID]=" &
Me!PhotoID
DoCmd.OpenForm strFormName, , , strLinkCriteria

Brad H.
 
I

Iryna Roy

You have to have one filed which should help you define the same record. For
Example CustomerID or which key do you have?
This field should be in both forms. (You could hide it on the first form if
you don't need it) BUT you should have the link. How you will define the
right photo???
stLinkCriteria = <here is the condition for the second form>
stLinkCriteria = "[KeyFieldNameOnTheSecondFrm]=" &
[KeyFieldNameOnTheFirtsName]
Where do you have the photo? on the different form or in subform?
If it is in the subform, you need to select Master and Child field in
subform properties and the form will have the photo in subform without any
additional coding.

If you have Main Form and want to open secod form with target photo (both
forms should have the key field, that you could define the right photo), you
need to create the button ON THE MAIN FORM and OnClick event put the code:

Dim strFormName As String
Dim strLinkCriteria As String

'Open the second form and go to same photo on the Second separate form
strFormName = "frmPhoto"

strLinkCriteria = "[PhotoID]=" & Forms![frmMain]!PhotoID
DoCmd.OpenForm strFormName, , , strLinkCriteria

Regards,
Iryna


Bradley C. Hammerstrom said:
Iryna,

As you suggested, I tried the following with reference to the subform, but
no good.

Dim strFormName As String
Dim strLinkCriteria As String

'Open the Main form and go to same photo on the subform
strFormName = "frmMain"
strLinkCriteria = "Forms!frmMain.frmMainSub1.Form![PhotoID]=" &
Me!PhotoID
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
what are you doing?
 
A

Albert D. Kallal

The problem here is the poster has said they are using a sub-form, and thus
you CAN NOT use the openform.


the simple solution here is to simply stuff the record source into the
sub-form.


me!SubFormName.Form.ReocrdSource = "select * from thetable where id = " &
me.id
 
I

Iryna Roy

Albert D. Kallal said:
The problem here is the poster has said they are using a sub-form, and thus
you CAN NOT use the openform.

READ the first e-mail
"User is viewing records on Form1 and finds one that has a photo he wants to
view using another form."
the simple solution here is to simply stuff the record source into the
sub-form.

If it is a SUB form, you DO NOT need to change record source. You need just
select master and child field and forms are linked without additional
coding. CHECk subform Properties

Regards,
Iryna
 
A

Albert D. Kallal

If it is a SUB form, you DO NOT need to change record source. You need just
select master and child field and forms are linked without additional
coding. CHECk subform Properties

Regards,
Iryna

If you took some time to actually read the original post, you would see that
the user is NOT talking about a one to many relation ship. The sub-form is
being used to display a picture, and not the "many" side of a relationship.
So, yes, if the users was trying to display some many records, then the
record source does not need to be changed.

The user does not want the picture to display until a button is clicked on
(again, read the original post). So, the simple solution is to simply set
the record source of the sub-form.
 
T

tina

hi bradley. i've read all the posts re your question.
remember that the subform you've added to Form2 is still a
form object; you can open it by itself. have you tried
using the code that iryna gave you to open that "subform"
form object directly, instead of opening Form2?
 
I

Iryna Roy

Albert D. Kallal said:
If you took some time to actually read the original post, you would see that
the user is NOT talking about a one to many relation ship. The sub-form is
being used to display a picture, and not the "many" side of a relationship.
So, yes, if the users was trying to display some many records, then the
record source does not need to be changed.

The user does not want the picture to display until a button is clicked on
(again, read the original post). So, the simple solution is to simply set
the record source of the sub-form.

Yep, probably you are right. Not very good way to show the info, as I think.
But if developer wants, it just his own problem. It means he will keep empty
space all the time?
 
A

Albert D. Kallal

Yep, probably you are right. Not very good way to show the info, as I think.
But if developer wants, it just his own problem. It means he will keep empty
space all the time?

If you are suggesting that the poster should not use a sub-form, then
certainly make that suggestion to the poster. There is no problem in making
this suggestion.

I also like a separate form.

However, the original poster was thinking that openform with args can be
used on a sub form. This is incorrect. Your suggestions to use openform to
solve this problem thus confused the poster. OpenForm will not, and cannot
be used for a sub form.

Hey, this is not a big deal. You are simply offering suggestions and ideas
and trying to help. I always am glad to see anyone offer help in this news
group! (and that is what you are doing!).
 
I

Iryna Roy

Albert D. Kallal said:
I also like a separate form.

However, the original poster was thinking that openform with args can be
used on a sub form. This is incorrect. Your suggestions to use openform to
solve this problem thus confused the poster. OpenForm will not, and cannot
be used for a sub form.

Sorry, it is my misunderstanding :)) I could not imaging that sombody will
try to open subform (sounds strange) using OpenForm, when it is alredy open.
I found one good article about sub-forms ;-)
http://www.attcanada.net/~kallal.msn/Articles/fog0000000005.html

Hey, this is not a big deal. You are simply offering suggestions and ideas
and trying to help. I always am glad to see anyone offer help in this news
group! (and that is what you are doing!).

When I start to program in MS Access, I always had help in this and other
groups. Need to pay now :)
 

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