Open related form

G

Guest

Hi all,

Using Access 2003 - I have two forms. We'll call them frmOne and frmTwo. I
want to open frmTwo from a command on frmOne and have it open to the same
record as the current ID. I can get this to work *fine* using:

DoCmd.OpenForm "frmTwo", , , "ID=" & ID

HOWEVER.... once I do this I am locked into that record. I can no longer
select another record with a different ID. I believe the solution may
involve "bookmark" but I rarely use it and am hitting a wall.

So, how do I open a second form going to the related record and still have
the ability to select a different record? Any ideas?

TIA

Aaron G
Philadelphia, PA
 
G

Guest

Pass the parameter to filter on through the OpenArgs
docmd.OpenForm "frmTwo",,,,,,Me.[ID]

On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
End If
 
G

Guest

Ofer,

Thanks for the help. I'm getting an error: "Compile Error: Method or Data
Member Not Found". It's highlighting the "Private Sub Form_Load() line in
yellow, then selecting the ".Setfocus" in the line "Me.ID.Setfocus".

This code is in the frmTwo and the command is being run from frmOne.

Any ideas?

Thanks again,

Aaron G
Philadelphia, PA

Ofer said:
Pass the parameter to filter on through the OpenArgs
docmd.OpenForm "frmTwo",,,,,,Me.[ID]

On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
End If

--
I hope that helped
Good Luck


Aaron G said:
Hi all,

Using Access 2003 - I have two forms. We'll call them frmOne and frmTwo. I
want to open frmTwo from a command on frmOne and have it open to the same
record as the current ID. I can get this to work *fine* using:

DoCmd.OpenForm "frmTwo", , , "ID=" & ID

HOWEVER.... once I do this I am locked into that record. I can no longer
select another record with a different ID. I believe the solution may
involve "bookmark" but I rarely use it and am hitting a wall.

So, how do I open a second form going to the related record and still have
the ability to select a different record? Any ideas?

TIA

Aaron G
Philadelphia, PA
 
G

Guest

I found the solution (mostly)! I didn't have the ID as a field on the form.
Putting the ID on the form allows the code to work, but now I have an
autonumber field mucking up my pretty form. I can't make it invisible
because it has to have the focus.

Is there a workaround?

Thanks

Aaron G
Philadelphia, PA

Ofer said:
Pass the parameter to filter on through the OpenArgs
docmd.OpenForm "frmTwo",,,,,,Me.[ID]

On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
End If

--
I hope that helped
Good Luck


Aaron G said:
Hi all,

Using Access 2003 - I have two forms. We'll call them frmOne and frmTwo. I
want to open frmTwo from a command on frmOne and have it open to the same
record as the current ID. I can get this to work *fine* using:

DoCmd.OpenForm "frmTwo", , , "ID=" & ID

HOWEVER.... once I do this I am locked into that record. I can no longer
select another record with a different ID. I believe the solution may
involve "bookmark" but I rarely use it and am hitting a wall.

So, how do I open a second form going to the related record and still have
the ability to select a different record? Any ideas?

TIA

Aaron G
Philadelphia, PA
 
G

Guest

Well, there is a work around, but mybe there is a better way
' I'll use my code, you change it to suit your data
On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.Id.visible=True
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
Me.[Another field name that is visible].SetFocus
Me.Id.visible=False
End If


--
I hope that helped
Good Luck


Aaron G said:
I found the solution (mostly)! I didn't have the ID as a field on the form.
Putting the ID on the form allows the code to work, but now I have an
autonumber field mucking up my pretty form. I can't make it invisible
because it has to have the focus.

Is there a workaround?

Thanks

Aaron G
Philadelphia, PA

Ofer said:
Pass the parameter to filter on through the OpenArgs
docmd.OpenForm "frmTwo",,,,,,Me.[ID]

On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
End If

--
I hope that helped
Good Luck


Aaron G said:
Hi all,

Using Access 2003 - I have two forms. We'll call them frmOne and frmTwo. I
want to open frmTwo from a command on frmOne and have it open to the same
record as the current ID. I can get this to work *fine* using:

DoCmd.OpenForm "frmTwo", , , "ID=" & ID

HOWEVER.... once I do this I am locked into that record. I can no longer
select another record with a different ID. I believe the solution may
involve "bookmark" but I rarely use it and am hitting a wall.

So, how do I open a second form going to the related record and still have
the ability to select a different record? Any ideas?

TIA

Aaron G
Philadelphia, PA
 
G

Guest

Ofer,

I was just logging in to let you know that I had come to the same
conclusion. Changing visibility before and after is an easy solution that
works like a charm. Thanks again for all your help.

Aaron G
Philadelphia, PA

Ofer said:
Well, there is a work around, but mybe there is a better way
' I'll use my code, you change it to suit your data
On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.Id.visible=True
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
Me.[Another field name that is visible].SetFocus
Me.Id.visible=False
End If


--
I hope that helped
Good Luck


Aaron G said:
I found the solution (mostly)! I didn't have the ID as a field on the form.
Putting the ID on the form allows the code to work, but now I have an
autonumber field mucking up my pretty form. I can't make it invisible
because it has to have the focus.

Is there a workaround?

Thanks

Aaron G
Philadelphia, PA

Ofer said:
Pass the parameter to filter on through the OpenArgs
docmd.OpenForm "frmTwo",,,,,,Me.[ID]

On the form load event of form2, run the code
If Not IsNull(Me.OpenArgs) Then
Me.ID.SetFocus
DoCmd.FindRecord Me.OpenArgs, , True, , True
End If

--
I hope that helped
Good Luck


:

Hi all,

Using Access 2003 - I have two forms. We'll call them frmOne and frmTwo. I
want to open frmTwo from a command on frmOne and have it open to the same
record as the current ID. I can get this to work *fine* using:

DoCmd.OpenForm "frmTwo", , , "ID=" & ID

HOWEVER.... once I do this I am locked into that record. I can no longer
select another record with a different ID. I believe the solution may
involve "bookmark" but I rarely use it and am hitting a wall.

So, how do I open a second form going to the related record and still have
the ability to select a different record? Any ideas?

TIA

Aaron G
Philadelphia, PA
 

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