N
Neil Cash
I have a main form with a subform on it. Within the subform I have a command
button that opens another form depending on what the value of the combo box
next to it contains. What I would like for the opened form to do, is to go
to a record that matches a field in the main form [Project Number]. And if
one doesn't exist, I'd like it to create a new record with the Project Number
filled in from the main form. I've tried this goto record command thus far
to go to the record containing the Project Number:
Dim strCriteria As String
Dim rs As Recordset
strCriteria = "[Project_Number] = " & Forms("Plan Status").[ProjectNumber]
Set rs = Me.RecordsetClone
rs.FindFirst strCriteria
If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.Project_Number = Forms("Plan Status").ProjectNumber
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
It does exactly what I want it to with a new record, except it inserts a new
record every time, despite the fact that there is a match. Any ideas?
Thanks in advance.
Neil
button that opens another form depending on what the value of the combo box
next to it contains. What I would like for the opened form to do, is to go
to a record that matches a field in the main form [Project Number]. And if
one doesn't exist, I'd like it to create a new record with the Project Number
filled in from the main form. I've tried this goto record command thus far
to go to the record containing the Project Number:
Dim strCriteria As String
Dim rs As Recordset
strCriteria = "[Project_Number] = " & Forms("Plan Status").[ProjectNumber]
Set rs = Me.RecordsetClone
rs.FindFirst strCriteria
If rs.NoMatch Then
DoCmd.GoToRecord , , acNewRec
Me.Project_Number = Forms("Plan Status").ProjectNumber
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
It does exactly what I want it to with a new record, except it inserts a new
record every time, despite the fact that there is a match. Any ideas?
Thanks in advance.
Neil