T
Tom
I need some help with a RunTime Error.
Here's the scenario:
I use multiple layers of subforms. Each subform uses combo boxes which
values drive the value of the next underlying subform.
On a given level (subform), I cannot use duplicate values. If I would
enter a duplicate value accidentally, then the Form_Error function below is
called and I need to press escape.
The AfterUpdate function below ensures that (if no duplicates are entered),
the when selecting/entering a new record from e.g. ComboBox1, the values of
ComboBox2 are adjusted (simple example would be the relationship between
"States" and "Cities").
Here's my problem:
1. Without the AfterUpdate function
- I cannot enter duplicates (which is good), but I won't update the next
tier of combo box values (which is bad)
2. With the AfterUpdate function
- I do update the next tier of combo boxes (which is good), but I now get a
Runtime error (which is bad)
Using both functions, the RunTime error (2455) indicates the following:
"Run-Time Error 2455. You entered an expression that has an invalid
reference to the property form/report".
My question now is the following:
How can modify both or either function to accomodate that I cannot enter
dups (Data_Err 3022) but I also can call the refresh query
"Me.NameofSubform.Form.CboBoxControl.Requery" without getting the error
2455?
************************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3022 Then
MsgBox "This duplicate value cannot be added!" & vbCrLf & "Push ESC
key to cancel"
Response = acDataErrContinue
End If
End Sub
************************
Private Sub Division_AfterUpdate()
Me.SubdatasheetExpanded = True
DoEvents
Me.NameofSubform.Form.CboBoxControl.Requery
End Sub
************************
Here's the scenario:
I use multiple layers of subforms. Each subform uses combo boxes which
values drive the value of the next underlying subform.
On a given level (subform), I cannot use duplicate values. If I would
enter a duplicate value accidentally, then the Form_Error function below is
called and I need to press escape.
The AfterUpdate function below ensures that (if no duplicates are entered),
the when selecting/entering a new record from e.g. ComboBox1, the values of
ComboBox2 are adjusted (simple example would be the relationship between
"States" and "Cities").
Here's my problem:
1. Without the AfterUpdate function
- I cannot enter duplicates (which is good), but I won't update the next
tier of combo box values (which is bad)
2. With the AfterUpdate function
- I do update the next tier of combo boxes (which is good), but I now get a
Runtime error (which is bad)
Using both functions, the RunTime error (2455) indicates the following:
"Run-Time Error 2455. You entered an expression that has an invalid
reference to the property form/report".
My question now is the following:
How can modify both or either function to accomodate that I cannot enter
dups (Data_Err 3022) but I also can call the refresh query
"Me.NameofSubform.Form.CboBoxControl.Requery" without getting the error
2455?
************************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3022 Then
MsgBox "This duplicate value cannot be added!" & vbCrLf & "Push ESC
key to cancel"
Response = acDataErrContinue
End If
End Sub
************************
Private Sub Division_AfterUpdate()
Me.SubdatasheetExpanded = True
DoEvents
Me.NameofSubform.Form.CboBoxControl.Requery
End Sub
************************