I am trying to insert a record into a table using the following code:-
CurrentDb.Execute ("INSERT INTO Jobs (startTime, finishTime, hoursWorked, description, mechanicID, nonProductive) VALUES ('" & txtstartTime.Text & "', '" & txtfinishTime.Text & "', '" & txthoursWorked.Text & "','" & txtdescription.Text & "','" & cmbmechanicNames.Value & "', '" & cbnonProductive.Value & "') ;")
But I am getting an error message saying I cannot reference a property or method of a control unless it has the focus.
Now obviously I can't set the focus for each of the control on the form where I am trying to get the values from in the INSERT statement, so what am I doing wrong?
*Edit - and if I use variables to get the values from the form rather than try and get them directly from the controls, and then use the values in the INSERT string, then the record isn't inserted to the table.
CurrentDb.Execute ("INSERT INTO Jobs (startTime, finishTime, hoursWorked, description, mechanicID, nonProductive) VALUES ('" & txtstartTime.Text & "', '" & txtfinishTime.Text & "', '" & txthoursWorked.Text & "','" & txtdescription.Text & "','" & cmbmechanicNames.Value & "', '" & cbnonProductive.Value & "') ;")
But I am getting an error message saying I cannot reference a property or method of a control unless it has the focus.
Now obviously I can't set the focus for each of the control on the form where I am trying to get the values from in the INSERT statement, so what am I doing wrong?
*Edit - and if I use variables to get the values from the form rather than try and get them directly from the controls, and then use the values in the INSERT string, then the record isn't inserted to the table.