ClaraBarton
Registered User.
- Local time
- Today, 05:28
- Joined
- Oct 14, 2019
- Messages
- 623
When running this code I get too few parameters:
The immediate window returns:
INSERT INTO t_ingredient (ingredientid, name) VALUES (55339, ingredienttext)
which looks right to me.
Code:
Public Function AddIngredients()
Dim dbs As DAO.Database
Dim rst As Recordset
Dim SQL As String
Dim intID As Long
Dim SQL2 As String
SQL = "SELECT t_recipeingredient.ingredienttext, t_recipeingredient.ingredientid " & _
"FROM t_recipeingredient " & _
"WHERE (((t_recipeingredient.ingredientid)=0))"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(SQL, dbOpenSnapshot)
intID = DMax("ingredientid", "t_ingredient") + 1
Do While Not rst.EOF
SQL2 = "INSERT INTO t_ingredient (ingredientid, name) VALUES (" & intID & ", " & "ingredienttext" & ")"
dbs.Execute SQL2, dbFailOnError
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Function
INSERT INTO t_ingredient (ingredientid, name) VALUES (55339, ingredienttext)
which looks right to me.