Error: "No value given for one or more required parameters

G

Gwen Crutcher

I keep getting the error "No value given for one or more required
parameters", but not sure why. Can anyone please look at my code snipet
and see if you see any reason why I could be getting this error. I am
just trying to update a record using MS Access 2003 as the front end.
This code is in VB.NET

Private Sub cmdUpdate_Click()
On Error GoTo Err_cmdUpdate_Click

Dim rstUsers As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
Dim strSQL As String


strSQL = "select dbo_tbl_Users.* from dbo_tbl_Users " & "where
dbo_tbl_Users!EmpRec=" & "'" & Me.cboEmpRec & "'"
rstUsers.Open strSQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic


If Not IsNull(Me.cboEmpRec.value) Then
rstUsers!EmpRec = Me.cboEmpRec.value
End If

If Not IsNull(Me.txtEmpID) Then
rstUsers!EmpID = Me.txtEmpID
Else
MsgBox "Please enter an employee number", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If


If Not IsNull(Me.txtEmpName) Then
rstUsers!EmpName = Me.txtEmpName
Else
MsgBox "Please enter an employee name", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.cboStatus.value) Then
rstUsers!Status = Me.cboStatus.value
Else
MsgBox "Please enter a status for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.txtUName) Then
rstUsers!UserName = Me.txtUName
Else
MsgBox "Please enter a user name for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.txtPass) Then
rstUsers!Password = Me.txtPass
Else
MsgBox "Please enter a password for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

rstUsers.Update
rstUsers.Close

MsgBox "Employee Record has been updated successfully.", vbOKOnly
DoCmd.Close
cboEmpRec = Null
txtEmpID = Null
txtEmpName = Null
txtPass = Null
cboStatus = Null
txtUName = Null
Set rstUsers = Nothing


Exit_cmdUpdate_Click:
Exit Sub

Err_cmdUpdate_Click:
MsgBox Err.Description
Resume Exit_cmdUpdate_Click

End Sub
 
B

Bob Barrows [MVP]

Gwen said:
I keep getting the error "No value given for one or more required
parameters", but not sure why. Can anyone please look at my code
snipet and see if you see any reason why I could be getting this
error. I am just trying to update a record using MS Access 2003 as
the front end. This code is in VB.NET

There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.

But read on.
Private Sub cmdUpdate_Click()
On Error GoTo Err_cmdUpdate_Click

Dim rstUsers As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
Dim strSQL As String


strSQL = "select dbo_tbl_Users.* from dbo_tbl_Users " & "where
dbo_tbl_Users!EmpRec=" & "'" & Me.cboEmpRec & "'"

Either debug your application and inspect the contents of strsql, or
look at the result of

Response.Write strSQL

If that doesn't tell you the problem, show it to us.
Lesson: you cannot debug a sql statement without knowing what it is.
While it helps to see the code that generates the statement, there is no
substitute for looking at the result of that code.

<snip of totally irrelevant stuff>

PS. You may wish to read up on sql injection and using parameters before
you get much further on in your learning curve.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top