A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Moving between forms



 
 
Thread Tools Display Modes
  #1  
Old March 3rd, 2010, 07:58 PM posted to microsoft.public.access
Jwil
external usenet poster
 
Posts: 23
Default Moving between forms

Hello,

I've made some buttons to navigate between forms. All the forms are related
so I would like to stay on the current record that is being displayed when
moving between the forms. Can someone please help me with this? I've tried
the GoToRecord function and in the offset put =[Forms]![EntryForm].[Record
ID] but it says that the expression is the wrong data type.

Thank you
  #2  
Old March 3rd, 2010, 08:08 PM posted to microsoft.public.access
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Moving between forms

DoCmd.OpenForm, , , "[KeyField] = " & Me.[KeyField]

is one way to open a form at a particular record.

Replace KeyField with your field name.
You only need the square brackets if there are spaces in the field name.
If KeyField is a text data type, use

"[KeyField] = """ & Me.[KeyField] & """"


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Jwil" wrote in message
...
Hello,

I've made some buttons to navigate between forms. All the forms are
related
so I would like to stay on the current record that is being displayed when
moving between the forms. Can someone please help me with this? I've tried
the GoToRecord function and in the offset put =[Forms]![EntryForm].[Record
ID] but it says that the expression is the wrong data type.

Thank you



  #3  
Old March 3rd, 2010, 10:12 PM posted to microsoft.public.access
Jwil
external usenet poster
 
Posts: 23
Default Moving between forms



"Jeanette Cunningham" wrote:

DoCmd.OpenForm, , , "[KeyField] = " & Me.[KeyField]


Thank you Jeanette. It is going to the record ok but it is filtering the
records so that only that particular record is shown. And when you press the
"filtered" button to unfilter the records it goes back to record 1. Is there
a way to do this without it filtering the records so that you can still move
back and forth between the records?
  #4  
Old March 4th, 2010, 01:23 AM posted to microsoft.public.access
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Moving between forms

Yes, you can do open form using open args, then apply a filter.

DoCmdOpenForm "FormName", , , , , , Me.[KeyField]

ON the form being opened, put a sub that does the filtering.

Private Sub FilterMe
Me.Filter = "[KeyField] = " & Me.OpenArgs
Me.FilterOn = True
End Sub

Call the FilterMe sub on the form's load event.


You can also use FindFirst instead of applying a filter.
FindFirst will show all the records, and if you make the record selectors
visible, the FindFirst code will move the arrow to the record that matches
the open args.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Jwil" wrote in message
...


"Jeanette Cunningham" wrote:

DoCmd.OpenForm, , , "[KeyField] = " & Me.[KeyField]


Thank you Jeanette. It is going to the record ok but it is filtering the
records so that only that particular record is shown. And when you press
the
"filtered" button to unfilter the records it goes back to record 1. Is
there
a way to do this without it filtering the records so that you can still
move
back and forth between the records?



  #5  
Old March 4th, 2010, 02:50 AM posted to microsoft.public.access
Jwil
external usenet poster
 
Posts: 23
Default Moving between forms



"Jeanette Cunningham" wrote:

Yes, you can do open form using open args, then apply a filter.

DoCmdOpenForm "FormName", , , , , , Me.[KeyField]

ON the form being opened, put a sub that does the filtering.

Private Sub FilterMe
Me.Filter = "[KeyField] = " & Me.OpenArgs
Me.FilterOn = True
End Sub

Call the FilterMe sub on the form's load event.


You can also use FindFirst instead of applying a filter.
FindFirst will show all the records, and if you make the record selectors
visible, the FindFirst code will move the arrow to the record that matches
the open args.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Jeanette,

I'm still having trouble . I tried the first method. It opened the form but
when I put the second code in the form's load event it just turned the filter
on. The code has Me.FilterOn = True so that seems to make sense. I would
like the filter off but to go to the record. I tried to figure out the
second method but I couldn't. I'm a beginner so could you please help me
with the findfirst method?

Thank you
  #6  
Old March 4th, 2010, 08:11 AM posted to microsoft.public.access
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Moving between forms

To be a bit more clear that we are both talking about the same thing.
Do you want to open the form with all its records showing?
Then you want to see the record selector arrow on the row that matches the
ID from the calling form( the one that opens this one)?

To use FindFirst

Private Sub FindMatchingRecord
With Me.RecordsetClone
.FindFirst "[KeyField] = " & Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End Sub


In the form's load event
Call FindMatchingRecord


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"Jwil" wrote in message
...


"Jeanette Cunningham" wrote:

Yes, you can do open form using open args, then apply a filter.

DoCmdOpenForm "FormName", , , , , , Me.[KeyField]

ON the form being opened, put a sub that does the filtering.

Private Sub FilterMe
Me.Filter = "[KeyField] = " & Me.OpenArgs
Me.FilterOn = True
End Sub

Call the FilterMe sub on the form's load event.


You can also use FindFirst instead of applying a filter.
FindFirst will show all the records, and if you make the record selectors
visible, the FindFirst code will move the arrow to the record that
matches
the open args.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Jeanette,

I'm still having trouble . I tried the first method. It opened the form
but
when I put the second code in the form's load event it just turned the
filter
on. The code has Me.FilterOn = True so that seems to make sense. I would
like the filter off but to go to the record. I tried to figure out the
second method but I couldn't. I'm a beginner so could you please help me
with the findfirst method?

Thank you



  #7  
Old March 8th, 2010, 08:40 PM posted to microsoft.public.access
Jwil
external usenet poster
 
Posts: 23
Default Moving between forms



"Jeanette Cunningham" wrote:

To be a bit more clear that we are both talking about the same thing.
Do you want to open the form with all its records showing?
Then you want to see the record selector arrow on the row that matches the
ID from the calling form( the one that opens this one)?

To use FindFirst

Private Sub FindMatchingRecord
With Me.RecordsetClone
.FindFirst "[KeyField] = " & Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
End Sub


In the form's load event
Call FindMatchingRecord


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Hi Jeanette,

I just came back in town and tried your code and it works perfectly. Thank
you very much.
  #8  
Old March 13th, 2010, 05:48 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default Moving between forms


"Jwil" wrote in message
...
Hello,

I've made some buttons to navigate between forms. All the forms are
related
so I would like to stay on the current record that is being displayed when
moving between the forms. Can someone please help me with this? I've tried
the GoToRecord function and in the offset put =[Forms]![EntryForm].[Record
ID] but it says that the expression is the wrong data type.

Thank you


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.