I'm having difficulty in creating the VBA code required to - on the click of a button on a Form - insert some data recorded on that Form into a Table (ie. one that isn't the source for the Form).
The data recorded on the Form that needs to be inserted into the (other) Table :
dtTestDate
numScore
numCorrection
numScore and numCorrection are both Number data type.
Most recently (been trying to resolve this over the last couple of days), the code I'm using (behind the On Click event of the button) has been :
It seems this variation of the code is just not working....though I'm not getting any error message. Based on some previous experience in using SQL to insert records into a Table, I suspect that the problem lies in the SQL code relating to numScore and numCorrection (and that the SQL relating to dtTestDate is not the problem).
Prompted by some Googling re the issue, I've tried some other variations of the code (removal of the single quotes round the numeric values; use of brackets round the numeric values; etc). Those variations give rise to an error message indicating that the number of values to be inserted (three in this case) doesn't tally with the number of fields in the INSERT INTo part of the code (possibly because the VBA code re the two numeric values is not as it should be ?).
There's probably a really simple solution to this, but I can't see it right now, and I need to move on with this.
Can anyone help with this, please ?
Thanks in advance
The data recorded on the Form that needs to be inserted into the (other) Table :
dtTestDate
numScore
numCorrection
numScore and numCorrection are both Number data type.
Most recently (been trying to resolve this over the last couple of days), the code I'm using (behind the On Click event of the button) has been :
Code:
DoCmd.RunSQL "INSERT INTO tblTestScores (" & _
"dtTestDate, " & _
"numScore, " & _
"numCorrection)" & _
" VALUES (" & _
"Date()," & _
"' & 20 & ' ," & _
"' & -1 & ');"
It seems this variation of the code is just not working....though I'm not getting any error message. Based on some previous experience in using SQL to insert records into a Table, I suspect that the problem lies in the SQL code relating to numScore and numCorrection (and that the SQL relating to dtTestDate is not the problem).
Prompted by some Googling re the issue, I've tried some other variations of the code (removal of the single quotes round the numeric values; use of brackets round the numeric values; etc). Those variations give rise to an error message indicating that the number of values to be inserted (three in this case) doesn't tally with the number of fields in the INSERT INTo part of the code (possibly because the VBA code re the two numeric values is not as it should be ?).
There's probably a really simple solution to this, but I can't see it right now, and I need to move on with this.
Can anyone help with this, please ?
Thanks in advance