T
Tom
I have a form that contains only a combo box (CboMoveTo).
When selecting a value on the combo box from a source table (which contains
let's say all "possible values"), it brings up another form with the
subordinate record data of the selected value.
If there is no record for the selected value, it will then prompt me w/ the
msg box "Record Not found - Add New Record?".
I need help w/ modifying the AfterUpdate event function to achieve the
following (when selecting a value for which NO record exists).
1. If no record exists, cache the selected value (from the combo box) and
then automatically place it into the appropriate "field" [BodyName] on the
subform that contains the record data.
2. If no record exist and I do NOT want to enter a new record, have the
option to cancel out of this operation.
Is that possible? If so, does anyone could please give me some pointers as
to how I need to modify the function below?
Thanks in advance,
Tom
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Private Sub CboMoveTo_AfterUpdate()
' Record Selection
If Not IsNull(Me.CboMoveTo) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[BodyName] = """ & Me.CboMoveTo & """"
If rs.NoMatch Then
MsgBox "Record Not found - Add New Record?"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
' Open sfrmCustomers
On Error GoTo Err_Command01_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNatoBodies"
stLinkCriteria = "[BodyName]=" & "'" & Me![CboMoveTo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command01_Click:
Exit Sub
Err_Command01_Click:
MsgBox Err.Description
Resume Exit_Command01_Click
End Sub
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
When selecting a value on the combo box from a source table (which contains
let's say all "possible values"), it brings up another form with the
subordinate record data of the selected value.
If there is no record for the selected value, it will then prompt me w/ the
msg box "Record Not found - Add New Record?".
I need help w/ modifying the AfterUpdate event function to achieve the
following (when selecting a value for which NO record exists).
1. If no record exists, cache the selected value (from the combo box) and
then automatically place it into the appropriate "field" [BodyName] on the
subform that contains the record data.
2. If no record exist and I do NOT want to enter a new record, have the
option to cancel out of this operation.
Is that possible? If so, does anyone could please give me some pointers as
to how I need to modify the function below?
Thanks in advance,
Tom
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Private Sub CboMoveTo_AfterUpdate()
' Record Selection
If Not IsNull(Me.CboMoveTo) Then
If Me.Dirty Then
Me.Dirty = False
End If
Set rs = Me.RecordsetClone
rs.FindFirst "[BodyName] = """ & Me.CboMoveTo & """"
If rs.NoMatch Then
MsgBox "Record Not found - Add New Record?"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
' Open sfrmCustomers
On Error GoTo Err_Command01_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmNatoBodies"
stLinkCriteria = "[BodyName]=" & "'" & Me![CboMoveTo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command01_Click:
Exit Sub
Err_Command01_Click:
MsgBox Err.Description
Resume Exit_Command01_Click
End Sub
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&