Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run-time error '3061' question

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I am writing this piece of code to UPDATE the database. When the code is run, I get "run-time error '3061', too few parameters expect 1" Dont know how to fix this problem. Need help.

Private Sub Dx_AfterUpdate()
Dim rstPtDx As Recordset
Dim strSQL As String
Dim strDx As String
Dim db As Database


Set db = CurrentDb
strSQL = "SELECT * FROM PtDx WHERE AdmitID=[forms]![admitpt]![admitsubform]![admit id]"
Set rstPtDx = db.OpenRecordset(strSQL)
Do Until rstPtDx.EOF
strDx = rstPtDx!Diagnosis & ", " & rstPtDx!ICDP & ";"
rstPtDx.MoveNext
Loop

CurrentDb.Execute "UPDATE [ADmission Detail] SET DXCharge = strDx Where AdmitID = [forms]![admitpt]![admitsubform]![admit id]"

end sub

Thank you everybody who give me help

Haijun
 
The message refers to your SQL statement (strSQL). It is my guess that AdmitID is not the correct field name in the table PtDx.

A good tip is just before the set rstPtDx statement, write "debug.pring strSQL" (without the quotes). After the statement has executed goto your debug screen (ctrl G). Copy and paste the SQL statement in Access QBE (Queries-New-SQL view) and run it. You will get a more informative statement of what the problem and you will also see what the results of a valid SQL statement will return.

Hope this Helps,
Rewdee
 
Thank you for your informative tips. I just tried it and fix the problem and other problem as well.

Big thanks

Haijun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top