Hi,
I'm trying to run a query and get the AutoIncrement ID Returned to me but i get this error "Too few parameters. Expected 3." On this line:
And this is my whole thing:Code:db.Execute ("INSERT INTO Loan([Copy ID], [Employee ID], [Loan Date], [Due Date]) VALUES (List2.Value, Combo4.Value, Date(), Calendar7.Value)")
Code:Private Sub AddLoan_Click() If List2.ListIndex = -1 Then MsgBox ("Please select a copy to loan out.") ElseIf Combo4.ListIndex = -1 Then MsgBox ("Please select the employee.") Else 'Add the loan entry 'Get Insert ID Dim db As DAO.Database Dim rs As DAO.Recordset Set db = DBEngine(0)(0) db.Execute ("INSERT INTO Loan([Copy ID], [Employee ID], [Loan Date], [Due Date]) VALUES (List2.Value, Combo4.Value, Date(), Calendar7.Value)") Set rs = db.OpenRecordset("SELECT @@IDENTITY AS LastID;") ShowIdentity = rs!LastID MsgBox (ShowIdentity) rs.Close Set rs = Nothing Set db = Nothing 'Update the copy and set it to On Loan Dim updateString updateString = "UPDATE Copy SET [Availability]='On Loan' WHERE [Copy ID]=List2.Value" End If End Sub


Reply With Quote

