I have a small problem I am not sure how to correct. I am running the following code from a button in frmSearch. It is all working with a few small quirks. The button does a quick check to make sure only one record is selected. If only one record is selected, it runs the code in red below. When it opens frmTaskDetails instead of having the single record, it has two, the record I want and a new record with no data. I know it is because in the Open event on frmTaskDetails I have the following code: DoCmd.GoToRecord , "", acNewRec. Is it possible to skip this somehow?
Private Sub butIndOpenRecToMod_Click()
'Check to see if NO selections are made. If none, display message box
If DCount("*", "qrySrchAfterSelections") = 0 Then
MsgBox "You must select at least one task to modify. Try again.", vbOKOnly, "Task Selection Error"
Exit Sub
End If
'Check to make sure only one selection is made. If more than one, display message box
If DCount("*", "qrySrchAfterSelections") > 1 Then
MsgBox "You can only select one record to modify. Try again.", vbOKOnly, "Task Selection Error"
Else
'Since only one record is selected, run the code to open frmTaskDetails to the selected record in order to modify
DoCmd.OpenForm "frmTaskDetails", acNormal, "", "[TaskSrch]=" & chkSearch, , acNormal
End If
End Sub
Private Sub butIndOpenRecToMod_Click()
'Check to see if NO selections are made. If none, display message box
If DCount("*", "qrySrchAfterSelections") = 0 Then
MsgBox "You must select at least one task to modify. Try again.", vbOKOnly, "Task Selection Error"
Exit Sub
End If
'Check to make sure only one selection is made. If more than one, display message box
If DCount("*", "qrySrchAfterSelections") > 1 Then
MsgBox "You can only select one record to modify. Try again.", vbOKOnly, "Task Selection Error"
Else
'Since only one record is selected, run the code to open frmTaskDetails to the selected record in order to modify
DoCmd.OpenForm "frmTaskDetails", acNormal, "", "[TaskSrch]=" & chkSearch, , acNormal
End If
End Sub