Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Red face Unanswered: Query values and target fields don't match

    Well, what I'm trying to do is to make 4 combo-boxes add new data to a previously(empty) created table.
    This is the code I use:

    Private Sub Combo0_AfterUpdate()
    If IsNull(Combo0) Then Exit Sub Else Combo2.Locked = False
    End Sub

    Private Sub Combo2_AfterUpdate()
    If IsNull(Combo2) Then Exit Sub Else Combo4.Locked = False
    End Sub


    Private Sub Combo4_AfterUpdate()
    If IsNull(Combo4) Then Exit Sub Else Combo6.Locked = False
    End Sub


    Private Sub Combo6_AfterUpdate()
    If IsNull(Combo0) Then Exit Sub Else
    CurrentDb.Execute "INSERT INTO testtabel(AA, NL, ppp, BB) SELECT '" & Combo1 & "' as AA '" & Combo2 & "' as NL '" & combo3 & "' as ppp '" & Combo2 & "' as BB"
    End Sub

    As you see, the first three are to keep the combo locked until a choice has been made from the one predecessing it.
    Now when I run the form it always stops at currentDb.Execute, although I've created a table with just those fields.

    Any comments would be greatly appreciated.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    here are some things you could try:

    1.
    dim strSQL as string
    strSQL = "INSERT INTO testtabel(AA, NL, ppp, BB) SELECT '" & Combo1 & "' as AA '" & Combo2 & "' as NL '" & combo3 & "' as ppp '" & Combo2 & "' as BB"
    msgbox strSQL 'just to make sure your SQL says what you think it says
    CurrentDb.Execute strSQL

    2.
    you could add a FROM to your SELECT

    3.
    and terminate your SQL with ...as BB;"

    izy

Posting Permissions

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