This UPDATE query has me baffled. Should be simple.

R

Richard Hollenbeck

I'm stumped. I have identical code for B, C, D, and F, but A is first and
it's stopping here. Once the A part is fixed, I can just modify the B,C,D,
and F SQL statements to match. I can't see anything wrong with my code.

I'm getting an error MsgBox saying:
Run-time error '3061'
Too few parameters, Expected 2.
End|Debug|Help

Here's the subroutine:

Private Sub cmdSaveLetterGrades_Click()
'Inserts minimum and maximum grades for A, B, C, D, and F into the
tblOptions table

Dim StrSQL As String

lbl_LGMessages.ForeColor = 16711680
lbl_LGMessages.Caption = "Saving Changes. . ."

StrSQL = "UPDATE tblOptions SET tblOptions.minScore = txtAMin.value,
tblOptions.maxScore = txtAMax.value WHERE (((tblOptions.letterGrade)='A'));"

'StrSQL is all on one line but takes two lines in this post
' txtAMin and txtAMax are text boxes on the form.

CurrentDb.Execute StrSQL, dbFailOnError

'followed here by the B, C, D, and F code

lbl_LGMessages.ForeColor = 0
lbl_LGMessages.Caption = ""

End Sub
 
W

Wayne Morgan

StrSQL = "UPDATE tblOptions SET tblOptions.minScore = txtAMin.value,
tblOptions.maxScore = txtAMax.value WHERE
(((tblOptions.letterGrade)='A'));"

You are literally inserting the text "txtAMin.Value" into the minScore
field, not the value held by this textbox. You need to concatenate the value
into the SQL statement. I assume the value is a number, so:

StrSQL = "UPDATE tblOptions SET tblOptions.minScore =" & Me.txtAMin & ",
tblOptions.maxScore =" & Me.txtAMax & " WHERE
(((tblOptions.letterGrade)='A'));"

If the values aren't numbers, this will need some modification.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top