I'm trying to write a public subroutine that returns a user to a specific row in a subform. Here's what I have so far...
Expand|Select|Wrap|Line Numbers
- Public Sub psubGoToRecordInSubform(ctrSubForm As Control, intID As Integer, strIDField As Object)
- 'returns cursor to a specific record in a subform
- Dim rs As Object
- Dim lngBookmark As Long
- 'set a variable to ID
- lngBookmark = intID
- DoCmd.GoToControl ctrSubForm.Name
- 'take it to the selected record
- Set rs = ctrSubForm.Form.RecordsetClone
- rs.FindFirst strIDField & " = " & lngBookmark
- ctrSubForm.Form.Bookmark = rs.Bookmark
- Set rs = Nothing
- End Sub
rs.FindFirst strIDField & " = " & lngBookmark
I can't seem to get the program to pick up strIDField properly. I've tried declaring it as a string, an object. I declared it as a control and used strIDField.Name and it errored. Access message said "Actual field name" is not a recognized field. This makes me wonder it this line is doing it's job:
DoCmd.GoToControl ctrSubForm.Name
Does anyone know what I'm doing wrong? (I mean besides trying to be a programmer :) )
Thanks,
Adam