Hello All,
I am very new to SQL and I am sure this is a silly question. I want to open a form at a specific record based upon ID, but if ID field is Null I want to open a new record. I have the opening at a specific ID down, but can't seem to get my If IsNull statement right to create a new record if the ID is null.
Here's what I've got right now, this part is working and I've blocked out the part I tried to add in that I can't get to work successfully because I don't know the right syntax. You can see the form I am trying to open is called "Contact Details". Basically I don't know what to put after the Else statement to get it to move onto the next section of code.
Private Sub txtOpenContactsfrmExtended_Click()
Dim strWhere As String
Dim rs As DAO.Recordset
strWhere = "[ID]=" & Me.[ID]
DoCmd.OpenForm "Contact Details"
'If IsNull(Me.[ID]) Then DoCmd.GoToRecord , "", acNewRec Else
With Forms![Contact Details]
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
.Bookmark = rs.Bookmark
End If
End With
Set rs = Nothing
End Sub
Thanks for any help you can give!
I am very new to SQL and I am sure this is a silly question. I want to open a form at a specific record based upon ID, but if ID field is Null I want to open a new record. I have the opening at a specific ID down, but can't seem to get my If IsNull statement right to create a new record if the ID is null.
Here's what I've got right now, this part is working and I've blocked out the part I tried to add in that I can't get to work successfully because I don't know the right syntax. You can see the form I am trying to open is called "Contact Details". Basically I don't know what to put after the Else statement to get it to move onto the next section of code.
Private Sub txtOpenContactsfrmExtended_Click()
Dim strWhere As String
Dim rs As DAO.Recordset
strWhere = "[ID]=" & Me.[ID]
DoCmd.OpenForm "Contact Details"
'If IsNull(Me.[ID]) Then DoCmd.GoToRecord , "", acNewRec Else
With Forms![Contact Details]
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
.Bookmark = rs.Bookmark
End If
End With
Set rs = Nothing
End Sub
Thanks for any help you can give!