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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
#9
|
|||
|
|||
Moving between forms
|
Thread Tools | |
Display Modes | |
|
|