P
Preston
Hi,
I am using VBA in Access 2007 to have a split form with a searchable text
box. On new record entry the code will search for an existing entry in the
recordset clone and if it exists will undo the control's changes and then set
the form's bookmark to the found record's bookmark. This all work fine if the
value is entered on the form half of the split form but if it is entered on
the datasheet portion then I am given a "No current record" message box or a
"Property not found" message box. It still finds the record but shows these
message boxes after the code is finished executing. The error is not in the
code and I am not given a debug option.
The form has two subforms.
Thank you for any help you can give.
Preston
UPDATE:
i have recreated the error with a simple database that has 2 tables parent
and child and a split form based on parent that has a subform based on child.
The following code is running on "current" event of the control containing
the value searched for.
<code>
Private Sub ID_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Dim so As String
Dim result As VbMsgBoxResult
If Me.NewRecord Then
Set rst = Me.RecordsetClone
Key = ID
rst.FindFirst ("ID = " & ID)
If Not rst.NoMatch Then
Cancel = True
Me.Undo
Me.Bookmark = rst.Bookmark
Me.Refresh
End If
Else
If Not IsNull(SvcOrderNum) And Not IsEmpty(SvcOrderNum) And _
TempVars!sonum1 <> SvcOrderNum Then
result = MsgBox("You are about to change the ticket number." &
vbCrLf & _
"Continue?.", vbYesNo, "Confirm change...")
If result = vbNo Then
Me.SvcOrderNum.Undo
DoCmd.RunCommand acCmdUndo
End If
End If
End If
End Sub
</code>
I am using VBA in Access 2007 to have a split form with a searchable text
box. On new record entry the code will search for an existing entry in the
recordset clone and if it exists will undo the control's changes and then set
the form's bookmark to the found record's bookmark. This all work fine if the
value is entered on the form half of the split form but if it is entered on
the datasheet portion then I am given a "No current record" message box or a
"Property not found" message box. It still finds the record but shows these
message boxes after the code is finished executing. The error is not in the
code and I am not given a debug option.
The form has two subforms.
Thank you for any help you can give.
Preston
UPDATE:
i have recreated the error with a simple database that has 2 tables parent
and child and a split form based on parent that has a subform based on child.
The following code is running on "current" event of the control containing
the value searched for.
<code>
Private Sub ID_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Dim so As String
Dim result As VbMsgBoxResult
If Me.NewRecord Then
Set rst = Me.RecordsetClone
Key = ID
rst.FindFirst ("ID = " & ID)
If Not rst.NoMatch Then
Cancel = True
Me.Undo
Me.Bookmark = rst.Bookmark
Me.Refresh
End If
Else
If Not IsNull(SvcOrderNum) And Not IsEmpty(SvcOrderNum) And _
TempVars!sonum1 <> SvcOrderNum Then
result = MsgBox("You are about to change the ticket number." &
vbCrLf & _
"Continue?.", vbYesNo, "Confirm change...")
If result = vbNo Then
Me.SvcOrderNum.Undo
DoCmd.RunCommand acCmdUndo
End If
End If
End If
End Sub
</code>