Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183

    Red face Unanswered: Not In List Event of Combo

    I have combo box based on query.

    Query : SELECT tblWorkers.ID, [tblWorkers].[WLName] & "," & [tblWorkers].[HFName] AS HomeWorker
    FROM tblWorkers;

    I want to use NoInList event for the combo box. When user don't see the value they want they can type in new data to add new record to the table. This is the code i wrote but i'm getting error since i have combine WFName and WLName as "HomeWorker"

    Any Solution ?

    Dim strsql
    Dim NewFirst As String
    Dim NewLast As String
    Dim CommaPosition As Integer

    CommaPosition = InStr(NewData, ",")
    If CommaPosition = 0 Then
    MsgBox "Your value has no comma."
    Exit Sub
    End If
    NewLast = Trim(Left(NewData, CommaPosition - 1))
    NewFirst = Trim(Mid(NewData, CommaPosition + 1))
    MsgBox "Record does not exist. Creating new Record."
    strsql = "Insert Into tblWorkers (WFName], [WLname]) values ('" & NewFirst & "','" & NewLast & "')"
    'MsgBox strsql
    CurrentDb.Execute strsql, dbFailOnError
    Response = acDataErrAdded


    Thanks in advance
    Skharva

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Where is it erroring ?

    I see in your statement:

    strsql = "Insert Into tblWorkers (WFName], [WLname]) values ('" & NewFirst & "','" & NewLast & "')"


    that you are missing a left bracket in front of the WFName field.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Sep 2003
    Location
    Raleigh, NC
    Posts
    183
    Originally posted by PracticalProgram
    Where is it erroring ?

    I see in your statement:

    strsql = "Insert Into tblWorkers (WFName], [WLname]) values ('" & NewFirst & "','" & NewLast & "')"


    that you are missing a left bracket in front of the WFName field.
    Thanks........I added the missing left bracket and it wrks fine now
    Skharva

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •