F
Fredrated
I have read the posts and visited the vb links related to this action, but
still can't get it to work properly in my combo notinlist event. After
inserting the new item into the underlying table, the request to requery the
combo box results in the error (code follows): 'Run time error 2118 You must
save the current field before you run the requery action'
combo box properties are
Row Source Type: Table/Query
Row Source: SELECT tStaff.desc FROM tStaff;
Limit to list: yes
Column Count: 1
Bound Column: 1
not-in-list code is:
------------------------
Private Sub Combo0_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
If MsgBox("The employee '" & NewData & "' is not on the list." & vbCrLf &
"Add them?", vbYesNo) = vbYes Then
strSQL = "INSERT INTO tStaff ( [desc] ) SELECT " & Chr(34) & NewData &
Chr(34) & " AS exp1;"
Call RunSQLquery(strSQL)
Me.Combo0.Requery
Else
Response = acDataErrContinue
End If
ExitCbo:
Exit Sub
End Sub
-----------------------------
RunSQLquery is a public function which creates a temporary querydef out of
the passed string, then executes it. This works and the item is added to the
table.
But, when I ask the combo box to requery itself after the item is added, I
get the error given at the beginning of this post.
Any ideas?
Thanks in advance for any help.
Fred
still can't get it to work properly in my combo notinlist event. After
inserting the new item into the underlying table, the request to requery the
combo box results in the error (code follows): 'Run time error 2118 You must
save the current field before you run the requery action'
combo box properties are
Row Source Type: Table/Query
Row Source: SELECT tStaff.desc FROM tStaff;
Limit to list: yes
Column Count: 1
Bound Column: 1
not-in-list code is:
------------------------
Private Sub Combo0_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
If MsgBox("The employee '" & NewData & "' is not on the list." & vbCrLf &
"Add them?", vbYesNo) = vbYes Then
strSQL = "INSERT INTO tStaff ( [desc] ) SELECT " & Chr(34) & NewData &
Chr(34) & " AS exp1;"
Call RunSQLquery(strSQL)
Me.Combo0.Requery
Else
Response = acDataErrContinue
End If
ExitCbo:
Exit Sub
End Sub
-----------------------------
RunSQLquery is a public function which creates a temporary querydef out of
the passed string, then executes it. This works and the item is added to the
table.
But, when I ask the combo box to requery itself after the item is added, I
get the error given at the beginning of this post.
Any ideas?
Thanks in advance for any help.
Fred