E
Emma
Hi I have the following code it creates a new record in the database,
unfortunately it isn't wring a blank form to the screen, I'm not sure if this
is realted to may last question acNext, but here's the code anyhow, (I
borrowed it from Klatuu, it worked fine for the purpose he helped me with).
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
unfortunately it isn't wring a blank form to the screen, I'm not sure if this
is realted to may last question acNext, but here's the code anyhow, (I
borrowed it from Klatuu, it worked fine for the purpose he helped me with).
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