0
votes

I have the following code:

Private Sub Command134_Click()

    Dim strInsert As String
    Set db = CurrentDb()
    strInsert = "INSERT INTO [SEMP Documentation] (Staff_Name) VALUES " & (Staff_Name.Value) & ");"
    MsgBox (strInsert)

    Debug.Print staffname
    db.Execute staffname, dbFailOnError
End Sub

Staff_Name is a combo box on a Microsoft Access form that has the name of 10 or so individuals, each with their own index.

The message box has the Staff_Name.Value call producing the index rather than the actual text name. For reference, the values in the combo box are pulled from a table, where the first column is the staff's index and the second column is the staff's name.

The user picks which person they are.

Secondly, the db.Execute statement fails; the table name is SEMP documentation that I am trying to insert into - "The Microsoft Access database engine cannot find the input table "

any help appeciated

1
why do you have a spaced table name? - RoMEoMusTDiE
I changed it and still problems. - bdpolinsky

1 Answers

1
votes

try this

 "INSERT INTO [SEMP Documentation] (Staff_Name) VALUES ('" & (Staff_Name.Value) & "');"

2nd prob is

db.Execute staffname, dbFailOnError

should be db.Execute strInsert, dbFailOnError