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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3061. Too few parameters expected 1 (What's wrong with my code?)

Status
Not open for further replies.

sisieko

Programmer
Jun 13, 2004
56
US
I get this error when i check and uncheck my checkbox.
The checkbox is located on a form and when it's checked it's supposed to feed data into a small table.

When i click on it. I get this "Error 3061. Too few parameters expected 1" What could be wrong here?


Code:
Private Sub chkNoSupportHrs_AfterUpdate()
On Error GoTo Err_ChkBox_Click
Dim MySQL As String
    
If Me.chkNoSupportHrs Then
   '-- CheckBox going to "Checked" state
   MySQL = "Insert into tblNoSupportHrs(sID, WeekEnding)" & _
        "Values(" & Me.txtResource & ", """ & Me.Text18 & """)"
Else
   '-- CheckBox going to "UnChecked" state
   MySQL = "DELETE * FROM tblNoSupportHrs WHERE sID = " & Me.txtResource
End If

CurrentDb().Execute MySQL, dbFailOnError

Exit_ChkBox_Click:
   Exit Sub

Err_ChkBox_Click:
   MsgBox "Error No:    " & Err.Number & vbCr & _
   "Description: " & Err.Description
   Resume Exit_ChkBox_Click

End Sub

 
How are ya sisieko . . .
Code:
[blue][purple][b]change:[/b][/purple]
   Dim MySQL As String
[purple][b]to:[/b][/purple]
   Dim MySQL As String, DQ as String

   DQ=""""


[purple][b]change:[/b][/purple]
      MySQL = "Insert into tblNoSupportHrs(sID, WeekEnding)" & _
        "Values(" & Me.txtResource & ", """ & Me.Text18 & """)"
[purple][b]to:[/b][/purple]
   MySQL = "Insert into tblNoSupportHrs (sID, WeekEnding) " & _
           "Values(" & DQ & Me.txtResource & DQ & ", " & _
                       DQ & Me.Text18 & DQ & ");"[/blue]

Calvin.gif
See Ya! . . . . . .
 
Ohhh Splendid!!! this works :D :D

When i check it works.

However, when i uncheck, I still get the error. Can you help me fix my delete code also?

Code:
   MySQL = "DELETE * FROM tblNoSupportHrs WHERE sID = " & Me.txtResource

 
Okay. I got this.

THanks TheAceMan1!! You are the best!! *muah

Works nice.

 
umm... im back again. I am having trouble with this.
Can you check my code please? Thanks.


Code:
MySQL = "DELETE * FROM tblNoSupportHrs WHERE [sID] = " & Me.txtResource & _
            "And" & DQ & [WeekEnding] =& DQ & Me.Text18 & DQ & ";"

 
MySQL = "DELETE * FROM tblNoSupportHrs WHERE [sID] = " & DQ & Me.txtResource & DQ & _
" And [WeekEnding] = " & DQ & Me.Text18 & DQ & ";"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV :D
That works great!

While i am on this issue.

Code:
    MySQL = "SELECT WeekEnding from tblNoSupportHrs WHERE [[sID] = " & DQ & Me.txtResource & DQ & _
        " And [WeekEnding] = " & DQ & Me.Text18 & DQ & ";"
        
        If Me.Text18 = MySQL Then
            [b]Me.chkNoSupportHrs[/b]
        Else
        End If

I am trying to checkthis box If true and do nothing if else. How do you tell it to check ur box in vba.


Feel free to curse me ;)



 
If DLookUp("WeekEnding", "tblNoSupportHrs", "sID=" & DQ & Me.txtResource & DQ " AND WeekEnding=" & DQ & Me.Text18 & DQ) = Me.Text18 Then
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks again PHV,
I am attaching this code to the onload event of a form bound to a table.
So that if data exits in another tiny table (check this box).

Here is what i have at the onload event:
Code:
Private Sub Form_Load()
Dim DQ As String
DQ = """"

If DLookup("WeekEnding", "tblNoSupportHrs", "sID=" & DQ & Me.txtResource & DQ & " AND WeekEnding=" & DQ & Me.Text18 & DQ) = Me.Text18 Then
            Me.chkNoSupportHrs = True
        Else
        End If
End Sub

However, this does absolutely NOTHING. It doesn't check my box, even when i am sure there is data in the other table.

Am i on the right track?

 
What are the values of txtResource and Text18 when the form is loading ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The form is bound to a table and depending on the week selected, it populates those fields when it's loaded, through the form's record source.

code attached to the record source is as follows:
Code:
SELECT *
FROM dbo_LDR_Support
WHERE (((dbo_LDR_Support.Resource)=shortID()) AND ((dbo_LDR_Support.WeekEnding)=getSelectedWeek()))
ORDER BY dbo_LDR_Support.SupportID;

Pleaase let me know if i am not giving you enough info here

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top