notinlist event gives error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • Re: Updating a record; saving the old one
    ... I know it's a requery, ... Private Sub cmdSaveOSRecord_Click ... (works with only Cashier declared and in String) ... Dim stLinkCriteria As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: notinlist event gives error
    ... inserting the new item into the underlying table, the request to requery ... Private Sub Combo0_NotInList(NewData As String, Response As Integer) ...
    (microsoft.public.access.formscoding)
  • Re: floyd problem
    ... " Check your trem edges and posts. ... next to the string tree is the locking ... "posts" that you'll see embeded into your guitar near the bridge. ...
    (alt.guitar.beginner)
  • Re: Data data from a Data Table
    ... I hadn't come back to check for posts on this after your pseudocode was ... I may end up using that pseudocode to present a report or something as I get ... Public Function fBuildSQL(strIN As String) As String ... Dim iCount As Long ...
    (microsoft.public.access.modulesdaovba)
  • Re: VB or C# for SQL Server
    ... Bob, ... I was just reading through the posts, and got to the part where you ... I was actually doing something similiar, where I needed to control the ... Public Sub Button_Click ...
    (microsoft.public.dotnet.framework.adonet)