ClaraBarton
Registered User.
- Local time
- Today, 05:16
- Joined
- Oct 14, 2019
- Messages
- 623
This isn't working so smoothly. I need an ID on a new record before I can add to the subform but the BeforeUpdate kicks in and won't let me move on because all fields aren't complete.
Is there a simple fix here?
Code:
Private Sub btnNew_Click()
On Error GoTo btnNew_Click_Error
If Me.Dirty Then
Me.Created = Date
Me.Dirty = False
End If
With Me.txtRecipe
.BorderStyle = 1
.SetFocus
End With
AddNewRecipe
On Error GoTo 0
Exit Sub
Private Sub AddNewRecipe()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT * FROM t_recipe WHERE 1=0;"
Set rs = db.OpenRecordset(strSQL)
With rs
.AddNew
![createdate] = Date
.Update
.Bookmark = .LastModified
End With
Code:
Dim bDelete As Boolean
'Dim strSQL As String
bDelete = False
'If previous new record is already there or they tried
'to delete just the name or they forgot the cookbook
If (Me!Recipe = "<New Recipe>") Or _
(Me!Recipe = "") Or _
IsNull(Me.cookbookidfk) Then
If MsgBox("Recipe Name and Cookbook are required. Do you want to " _
& "discard this new record?", vbOKCancel) = vbOK Then
bDelete = True
Else
Cancel = True
End If
End If
Last edited: