I'm trying to write to an access database through a VB program. The user types in values and I want to write these to the database using the INSERT statement. This is what I have:
Set gdbCurrent = _
OpenDatabase(App.Path & "\Recipes.mdb"
pstrSQL = "INSERT INTO tblRecipes(fldName, fldFoodType, fldCookIn, fldTime, fldIngredients, fldInstructions) " & _
"VALUES('txtName.Text', 'cboFoodType.Text', 'cboCookIn.Text', 'cboTime.Text', 'txtIngredients.Text', 'txtInstructions.Text')"
gdbCurrent.Execute pstrSQL
That code just passes what is in the quotes, ie: txtName.Text is written to the database. I also tried it without the single quotes and then I got an error: "Too few arguements."
Is there anyway to pass the values to the database????
Set gdbCurrent = _
OpenDatabase(App.Path & "\Recipes.mdb"
pstrSQL = "INSERT INTO tblRecipes(fldName, fldFoodType, fldCookIn, fldTime, fldIngredients, fldInstructions) " & _
"VALUES('txtName.Text', 'cboFoodType.Text', 'cboCookIn.Text', 'cboTime.Text', 'txtIngredients.Text', 'txtInstructions.Text')"
gdbCurrent.Execute pstrSQL
That code just passes what is in the quotes, ie: txtName.Text is written to the database. I also tried it without the single quotes and then I got an error: "Too few arguements."
Is there anyway to pass the values to the database????