Problem Editing A Specific Record From A Subform In Another Form

rlm

Retired Navy Veteran
Local time
Yesterday, 19:12
Joined
Nov 25, 2011
Messages
18
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?:confused:
Help with this would be HIGHLY APPRECIATED.
 
Discard the code in your post above.

Use the double click event of a textbox on your form (or you could put a button to open the task edit form).

The code will be something like:

DoCmd.OpenForm "TaskEditForm", , , "[TaskID] = " & Me.TaskID
 
Outstanding. It works wonderful.
Your the best. Thanks alot!!!!!:)
 

Users who are viewing this thread

Back
Top Bottom