E
Emma
Can someone help me with this code. I would like a new case note to be made
when the user clicks on the button. However the code I have meshed together
keeps bringing up the first record instead of a brand new record.
Private Sub newrcd_Click()
Dim intNewID As Integer
Dim strSQL As String
On Error GoTo Err_newrcd_Click
'Find the current high number and Add 1 to it
intNewID = Nz(DMax("[ID]", "[Case Note Client]"), 0) + 1
'Write it to the table ASAP to avoid duplicates in a multi user environment
strSQL = "INSERT INTO [Case Note Client] (ID) SELECT " & _
intNewID & " AS Dummy;"
CurrentDb.Execute strSQL, dbFailOnError
'Make the new record the current record
Me.Requery
With Me.RecordsetClone
.FindFirst "[ID] = " & intNewID & ""
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
'Me![Case Worker].Value = CurrentUser
Exit_newrcd_Click:
Exit Sub
Err_newrcd_Click:
MsgBox Err.Description
Resume Exit_newrcd_Click
End Sub
when the user clicks on the button. However the code I have meshed together
keeps bringing up the first record instead of a brand new record.
Private Sub newrcd_Click()
Dim intNewID As Integer
Dim strSQL As String
On Error GoTo Err_newrcd_Click
'Find the current high number and Add 1 to it
intNewID = Nz(DMax("[ID]", "[Case Note Client]"), 0) + 1
'Write it to the table ASAP to avoid duplicates in a multi user environment
strSQL = "INSERT INTO [Case Note Client] (ID) SELECT " & _
intNewID & " AS Dummy;"
CurrentDb.Execute strSQL, dbFailOnError
'Make the new record the current record
Me.Requery
With Me.RecordsetClone
.FindFirst "[ID] = " & intNewID & ""
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
'Me![Case Worker].Value = CurrentUser
Exit_newrcd_Click:
Exit Sub
Err_newrcd_Click:
MsgBox Err.Description
Resume Exit_newrcd_Click
End Sub