Move to Current Record in New Form without filltering records

  • Thread starter Thread starter Tom K via AccessMonster.com
  • Start date Start date
T

Tom K via AccessMonster.com

Hi
I have two forms that get there data from the same query. When I change a
record in one form I would like to have the other form go to that same record.
Yet, I dont want to have the records filtered so it only displays that record.
I need to have all the records displayed, but have the record that I changed
be the current record. The move from one form to the other by using comand
buttons that run Open Form macros. Is there a way to do this by changing my
macros. I dont want to get lost in VBA.

Thanks
 
Sadly, you can't get there with a Macro. The OpenForm method has an OpenArgs
arguement not available to a macro.
To do what you want, you will have to pass the key of the current record to
the form you are opening and in the Open event of the form, go to that record.
 
Ok,

I will go ahead and ask even though I'm not sure I can program it. How could
I do it in VBA? My main form is called frmAddress. The other form is called
frmNewAddress. I would like to attach it to my command button that I use to
save the new record and close the form on the form frmNewAddress. I have a
Primary Key field on both forms called AddressID.

Thanks for the help
 
Here is some sample code for how to do what you seek. Post back with
questions.

Pass the "filter" string as the OpenArgs argument for the OpenForm action
(run this code in the event procedure for the command button's Click event):
DoCmd.OpenForm "frmMyForm", OpenArgs:="Id = " & me.Id

Now, in the frmMyForm form, let's add code in the form's Load event that
will move it to the desired record:

Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If .NoMatch = False Then Me.Bookmark = .Bookmark
End With
End If
End Sub
 
Thanks,
I tried but I could not get it to work. I need the button to close the form
and the other form witch stays open moves to the record.

Thanks but this is well beyond my skill level.
Here is some sample code for how to do what you seek. Post back with
questions.

Pass the "filter" string as the OpenArgs argument for the OpenForm action
(run this code in the event procedure for the command button's Click event):
DoCmd.OpenForm "frmMyForm", OpenArgs:="Id = " & me.Id

Now, in the frmMyForm form, let's add code in the form's Load event that
will move it to the desired record:

Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If .NoMatch = False Then Me.Bookmark = .Bookmark
End With
End If
End Sub
Hi
I have two forms that get there data from the same query. When I change a
[quoted text clipped - 10 lines]
 
If you want to stay with macros only, then it will be next to impossible to
synchronize the forms the way you want to do. I can envision a somewhat
complicated process that might be set up, but believe me that it is much
simpler and less error-prone to do it with VBA.

I wish you well nonetheless!

--

Ken Snell
<MS ACCESS MVP>



Tom K via AccessMonster.com said:
Thanks,
I tried but I could not get it to work. I need the button to close the
form
and the other form witch stays open moves to the record.

Thanks but this is well beyond my skill level.
Here is some sample code for how to do what you seek. Post back with
questions.

Pass the "filter" string as the OpenArgs argument for the OpenForm action
(run this code in the event procedure for the command button's Click
event):
DoCmd.OpenForm "frmMyForm", OpenArgs:="Id = " & me.Id

Now, in the frmMyForm form, let's add code in the form's Load event that
will move it to the desired record:

Private Sub Form_Load()
If Len(Me.OpenArgs & "") > 0 Then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If .NoMatch = False Then Me.Bookmark = .Bookmark
End With
End If
End Sub
Hi
I have two forms that get there data from the same query. When I change
a
[quoted text clipped - 10 lines]
 

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

Back
Top