I am very very new to Access and have been building a program to track tasks. The problem I'm having is I have my Assets table open by use of my Assets form. There is a subform called Tasks, in a database format, that only list related tasks to the Asset that is on the Assets Form. When I go to the Tasks Subform and click on a record, I want that record to open in another form called EditTaskForm for editing the data within that task. When I click on that record and it opens the EditTaskForm, it always pulls up the first record within the Tasks Table. I have used the following VBA code that I found on the web to try and locate the record and edit that record. The VBA that I'm trying from the Tasks Subform is as follow:
Private Sub Form_Click()
Set rst = Me.RecordsetClone
rst.FindFirst "[TaskID]=" & TaskID
If rst.NoMatch Then
' do something here if there is no match or just ignore it
Else
MsgBox (TaskID)
Me.Bookmark = rst.Bookmark
DoCmd.OpenForm "TaskEditForm"
End If
rst.Close
Set rst = Nothing
The MsgBox listed in the code above actually shows the correct TaskID, but when the TaskEditForm opens, it always opens to the first record within the Tasks Table instead of opening the record requested. The two related tables, Assets and Tasks use the field "TaskID" in both tables. The relation is set to these fields.
How can I get past this point and be able to edit the record I selected?
Help with this would be HIGHLY APPRECIATED.
Private Sub Form_Click()
Set rst = Me.RecordsetClone
rst.FindFirst "[TaskID]=" & TaskID
If rst.NoMatch Then
' do something here if there is no match or just ignore it
Else
MsgBox (TaskID)
Me.Bookmark = rst.Bookmark
DoCmd.OpenForm "TaskEditForm"
End If
rst.Close
Set rst = Nothing
The MsgBox listed in the code above actually shows the correct TaskID, but when the TaskEditForm opens, it always opens to the first record within the Tasks Table instead of opening the record requested. The two related tables, Assets and Tasks use the field "TaskID" in both tables. The relation is set to these fields.
How can I get past this point and be able to edit the record I selected?

Help with this would be HIGHLY APPRECIATED.