Results 1 to 3 of 3
  1. #1
    Andyjones is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    76

    not in edit list

    Private Sub cboOurPlayer_NotInList(NewData As String, Response As Integer)


    Dim strSQL1 As String
    Dim i As Integer
    Dim Msg As String

    'Exit this sub if the combo box is cleared
    If NewData = "" Then Exit Sub

    Msg = "'" & NewData & "' The Player is not currently in the list." & vbCr & vbCr
    Msg = Msg & "do you want to add it ?"

    i = MsgBox(Msg, vbQuestion + vbYesNo, "This is a new Player...")
    If i = vbYes Then
    strSQL1 = "Insert Into tblPlayers [PlayerFirstName] & " " & [PlayerLastName _
    "values ('" & NewData & "');"


    CurrentDb.Execute strSQL1, dbFailOnError
    Response = acDataErrAdded

    End If

    End Sub

    Highlighted in red i get a complie error msg. pls advise why it wont work

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I believe that your quotation marks are misplaced. Look at Allen Browne's solution

    http://allenbrowne.com/ser-27.html

    Alan

  3. #3
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    75
    Your insert statement is incorrect. You can't concatenate fields on the insert side of the statement.

    I'm assuming that your selected value has the first and last name concatenated together?
    If so, you need to parse the first and last name out of NewData

    Dim sName() as string
    sName = split(NewData)
    strSQL1 = "INSERT INTO tblPlayers (PlayerFirstName, PlayerLastName) VALUES ('" & sName(0) & "','" & sName(1) & "');"

    You may need to do some extra validation if your NewData values have more than 2 names, for instance a middle initial or something.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-05-2012, 08:39 PM
  2. Write "Edit List Items.." data back to original form.
    By ngahm in forum Database Design
    Replies: 33
    Last Post: 02-27-2012, 06:54 PM
  3. Replies: 23
    Last Post: 12-06-2011, 09:18 AM
  4. Replies: 4
    Last Post: 06-16-2011, 09:30 PM
  5. Edit List Items
    By Broderhol in forum Forms
    Replies: 3
    Last Post: 02-23-2011, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums