P
pk
Hi,
This is driving me up a wall. I am using the notinlist event for a combo
box, based on a query, 2 columns. The following properties are set:
Bound Column = 1
Column Count = 2
Column Width = 0.0; 1.5
Limit To List = Yes
Auto Expand = Yes
When a value is entered into the combo box I call a rules engine class
module passing the text that was entered. The rules engine assuming the
data passed calls a data engine class module that inserts the new value into
the table. The data engine procedure returns a true false to the rules
engine, that in turn returns a integer that equates to the access constants
used in this event.
I check if the return value equals the constant value of acDataErrAdded and
if it does set the Response argument of the event to the value of
acDataErrAdded.
This all works yet I continue to recieve the message "the item is not in the
list" . The standard access error message is not being suppressed. This
happens even if I run the code directly in the event handler.
Here are the code snippets
Form
Private Sub cboApplications_NotInList(NewData As String, Response As
Integer)
Dim intResponse As Integer
' pass the new app to the rules engine
intResponse =
moRulesEngine.ChangeOptions(DirtyPage:=Me.tabOptions.Pages(Index:="pgeProcess"))
If intResponse = acDataErrContinue Then
Response = acDataErrContinue
MsgBox Prompt:="insert of new app name failed"
Else
Response = acDataErrAdded ' value should equate to the constant
acDataErrAdded
End If
Rules Engine Snippet
Case Is = "pgeProcess"
strAppName = DirtyPage.Controls("cboApplications").Text
' pass entered name to rhe routine to check for valid length
blnCheckPassed = ValidateAppName(AppName:=strAppName)
If blnCheckPassed Then ' send the name to the data engine to
insert into the database
blnDataEngineResponse =
moDataEngine.AddListItem(ctl:=DirtyPage.Controls(Index:=("cboApplications")),
NewValue:=strAppName)
If blnDataEngineResponse Then
ChangeOptions = acDataErrAdded ' app name was added
successfully
Else
ChangeOptions = acDataErrContinue ' app name was not
added successfully
End If
Else
Err.Raise Number:=mconBASE_ERROR_NBR + 4,
Source:="RulesEngine.ChangeOptions", Description:="The length of the entered
text does not fit the column size."
End If
End Select
Data Engine Snippet
Public Function AddListItem(ctl As ComboBox, NewValue As String) As Boolean
Dim strErrorProcedure As String
Dim blnFuncResult As Boolean
On Error GoTo CantAddListItem
strErrorProcedure = "CMPSupport.basDataLayer.AddListItem"
With mocmd
Select Case ctl.Name
Case Is = "cboApplications"
.CommandType = adCmdStoredProc
.CommandText = "spInsertApp"
.Parameters.Append .CreateParameter(Name:="AppDesc",
Type:=adVarChar, Direction:=adParamInput, Size:=50, Value:=NewValue)
This is driving me up a wall. I am using the notinlist event for a combo
box, based on a query, 2 columns. The following properties are set:
Bound Column = 1
Column Count = 2
Column Width = 0.0; 1.5
Limit To List = Yes
Auto Expand = Yes
When a value is entered into the combo box I call a rules engine class
module passing the text that was entered. The rules engine assuming the
data passed calls a data engine class module that inserts the new value into
the table. The data engine procedure returns a true false to the rules
engine, that in turn returns a integer that equates to the access constants
used in this event.
I check if the return value equals the constant value of acDataErrAdded and
if it does set the Response argument of the event to the value of
acDataErrAdded.
This all works yet I continue to recieve the message "the item is not in the
list" . The standard access error message is not being suppressed. This
happens even if I run the code directly in the event handler.
Here are the code snippets
Form
Private Sub cboApplications_NotInList(NewData As String, Response As
Integer)
Dim intResponse As Integer
' pass the new app to the rules engine
intResponse =
moRulesEngine.ChangeOptions(DirtyPage:=Me.tabOptions.Pages(Index:="pgeProcess"))
If intResponse = acDataErrContinue Then
Response = acDataErrContinue
MsgBox Prompt:="insert of new app name failed"
Else
Response = acDataErrAdded ' value should equate to the constant
acDataErrAdded
End If
Rules Engine Snippet
Case Is = "pgeProcess"
strAppName = DirtyPage.Controls("cboApplications").Text
' pass entered name to rhe routine to check for valid length
blnCheckPassed = ValidateAppName(AppName:=strAppName)
If blnCheckPassed Then ' send the name to the data engine to
insert into the database
blnDataEngineResponse =
moDataEngine.AddListItem(ctl:=DirtyPage.Controls(Index:=("cboApplications")),
NewValue:=strAppName)
If blnDataEngineResponse Then
ChangeOptions = acDataErrAdded ' app name was added
successfully
Else
ChangeOptions = acDataErrContinue ' app name was not
added successfully
End If
Else
Err.Raise Number:=mconBASE_ERROR_NBR + 4,
Source:="RulesEngine.ChangeOptions", Description:="The length of the entered
text does not fit the column size."
End If
End Select
Data Engine Snippet
Public Function AddListItem(ctl As ComboBox, NewValue As String) As Boolean
Dim strErrorProcedure As String
Dim blnFuncResult As Boolean
On Error GoTo CantAddListItem
strErrorProcedure = "CMPSupport.basDataLayer.AddListItem"
With mocmd
Select Case ctl.Name
Case Is = "cboApplications"
.CommandType = adCmdStoredProc
.CommandText = "spInsertApp"
.Parameters.Append .CreateParameter(Name:="AppDesc",
Type:=adVarChar, Direction:=adParamInput, Size:=50, Value:=NewValue)