Hey guys,
Relatively new in access and programming and having a small problem. I'm trying to open a table and find a record where the ID value on the form matches the PK of the table and grabs that record so I can edit 2 fields.
The problem I'm running into is that rst.nomatch is always false and it always pulls the first record in the table. I've tried playing around with this for a few hours but always the same result.
Here's my code:
When debugging this, Me!txtID always returns the correct value, it's just that FindFirst always pulls the first record ([Hours_ID]=1) in the table. Everything I've tried, even using not rst.nomatch always returns that there's a match and it's always returning the first record as that match.
Thanks in advance!
Relatively new in access and programming and having a small problem. I'm trying to open a table and find a record where the ID value on the form matches the PK of the table and grabs that record so I can edit 2 fields.
The problem I'm running into is that rst.nomatch is always false and it always pulls the first record in the table. I've tried playing around with this for a few hours but always the same result.
Here's my code:
Code:
Dim db As DAO.Database
Dim rst As DAO.Recordset
dim i1 as integer
Set rst = db.OpenRecordset("tbl_hours", dbOpenSnapshot)
rst.MoveFirst
rst.FindFirst "[Hours_ID] = '" & Me!txtID & "'" 'Hours_ID is a number, long integer and the PK of tbl_hours. txtID is the field on the form which is a primary key, long integer (not sure if type matters)
i1 = rst!Hours_ID 'for debugging this always returns 1
rst.Edit 'everything below here works fine!
rst("Hours") = Me!fraHours
rst("Weekend") = Me!fraWeekends
rst.Update
rst.Close
Set rst = Nothing
When debugging this, Me!txtID always returns the correct value, it's just that FindFirst always pulls the first record ([Hours_ID]=1) in the table. Everything I've tried, even using not rst.nomatch always returns that there's a match and it's always returning the first record as that match.
Thanks in advance!