The code below works but I don’t understand the Values (line line 9). I keep getting error messages. Could someone add more fields to it, such as:
F24 into Ingredient2
F25 into Ingredient3
F26 into Ingredient4
G24 into Lot2
G25 into Lot3
G26 into Lot4
The Ingredient column and the Lot column will both have 30 rows for data.
F24 into Ingredient2
F25 into Ingredient3
F26 into Ingredient4
G24 into Lot2
G25 into Lot3
G26 into Lot4
The Ingredient column and the Lot column will both have 30 rows for data.
Code:
Sub Button10_Click()
Dim strSQL As String
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = False
strSQL = "INSERT INTO [Finished Batches] ([Production Date],[Lot_Number],[Ingredient1],[Amount1]) " & _
"VALUES (#" & Range("C5") & "#,'" & Range("D5") & "','" & Range("F23") & _
"'," & Range("G23") & ")"
With appAccess
.OpenCurrentDatabase ("C:\users\jay neuh\desktop\database\ss database.mdb")
.DoCmd.RunSQL strSQL, dbFailOnError
.CloseCurrentDatabase
End With
Set appAccess = Nothing
End Sub
Comment