I'm trying to move to a record that has a certain ID.
I tried the solution on this post: MS Access search for record by textbox instead of dropdown
but no success
Here's my code
Private Sub btnShowPrevious_Click()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[ID]=" & ParentID
If rs.NoMatch Then
MsgBox "Sorry, no such record '" & ParentID & "' was found.", _
vbOKOnly + vbInformation
Else
Me.Recordset.Bookmark = rs.Bookmark
End If
rs.Close
End Sub
It always hit no match but parentID = 1 and there's one record with ID = 1..
Anyone has an idea of what is wrong?
Thank you
The record source is this table:
CREATE TABLE [dbo].[ProposalFollowUp](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ProposalID] [int] NOT NULL,
[MillID] [int] NULL,
[ClientID] [int] NULL,
[Comment] [nvarchar](max) NULL,
[Method] [nvarchar](128) NULL,
[Contact] [int] NULL,
[ContactDate] [datetime] NULL,
[Done] [bit] NOT NULL,
[CreatedBy] [nvarchar](50) NULL,
[CreatedDate] [datetime] NULL,
[ModifiedBy] [nvarchar](50) NULL,
[ModifiedDate] [datetime] NULL,
[EAIEmployee] [nvarchar](50) NULL,
[PersonInCharge] [nvarchar](50) NULL,
[ParentID] [int] NULL,
here's a screenshot of the form properties
Finaly, if I show the navigation bar, I can see there's a filter. Probably because I open the form like this
DoCmd.OpenForm "ProposalsFollowUp", , , "[ID] = " & txtID, acFormEdit, acDialog
If I remove the filter, it works.
Alright Here's the final code
Private Sub btnShowPrevious_Click()
Dim parent As Integer
parent = ParentID
Me.Filter = ""
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[ID]=" & parent
If rs.NoMatch Then
MsgBox "Sorry, no such record '" & parent & "' was found.", _
vbOKOnly + vbInformation
Else
Me.Recordset.Bookmark = rs.Bookmark
End If
rs.Close
End Sub