Results 1 to 8 of 8
  1. #1
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156

    To few perimiters. Exopected 1 Run_Time Error 3061


    Hello everyone. I am trying to run this code and I keep getting the (To few perimiters. Exopected 1 Run_Time Error 3061) What the code does is count home many times a button is pushed and the " WHERE (((tblMystery.EntryDate)=Date()));" is part of current date.. Well that is what it is suppose to do. When I push the btnVisible button the error pops up when it is suppose to count 1 more click. Thank-you everyone. I am running Access 2016

    Code:
    Private Sub btnVisible_Click()
     CurrentDb.Execute "UPDATE tblMystery SET btnVisible.Clicks = Clicks + 1" & _
            " WHERE (((tblMystery.EntryDate)=Date()));"
            
        Me.Requery
    Me.TextBox2.Visible = True
    Dim rs As DAO.Recordset
    Me.TimerInterval = 0
    Set rs = CurrentDb.OpenRecordset("Select * From tblMysteryLog")
    rs.AddNew
    rs!StartOfTest = Me.txtSessionStart
    rs!EndOfTest = Now()
    rs!ActualMinutes = Me.txtActualMinutes
    rs!ActualSeconds = Me.txtActualSeconds
    rs.Update
    rs.Close
    Set rs = Nothing
    'MsgBox "Data logged.", vbOKOnly, "Logged"
      
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    I suspect btnVisible.Clicks should just be Clicks.

    However, if Clicks is Null, the calc will return Null. Consider: Nz([Clicks],0) + 1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    You need to update the clicks field value in the table ... not btnVisible
    Also, use date delimiters in the WHERE section of the query:

    Code:
    CurrentDb.Execute "UPDATE tblMystery SET tblMystery.Clicks = Clicks + 1" & _
            " WHERE (((tblMystery.EntryDate)= #" & Date & "#));"
    If not already in format mm/dd/yyy, then you need this:
    Code:
    CurrentDb.Execute "UPDATE tblMystery SET tblMystery.Clicks = Clicks + 1" & _
           " WHERE (((tblMystery.EntryDate)= #" & Format(Date,"mm/dd/yyyy") & "#));"
    Last edited by isladogs; 12-28-2017 at 03:26 PM. Reason: Added info

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    @ridders52, delimiters and concatenation not necessary. The SQL will evaluate Date() function. However, I think Date() is a VBA function (not SQL) and might be a tad more efficient to retrieve the date value and concatenate it instead of having the SQL call the VBA Date() function. But I doubt it is enough to make a noticeable difference.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    Ok my big mistake, I never explained the situation well enough. The btnVisible Button reveals the answer to the mystery. That text box is hidden until the boy gives up on the riddle and hits the btnVisible button to reveal the answer to the mystery. But I am also trying to set it up so that it keeps tracks of how many times he gives up and clicks the button. The code below the red text is code for the timer of how long it takes him to solve or give up. It works fine and the date part in the red code works fine just the number of clicks does not work properly.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,992
    @ridders52, delimiters and concatenation not necessary. The SQL will evaluate Date() function.
    True - I'm so used to selecting one or two dates on a form prior to doing a query like this that I went into automatic mode when replying ....

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Did you make the suggested edit to the SQL statement?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    CHEECO is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2016
    Posts
    156
    Yes I did but I don't think I did right so It would not work. However I did get it working. I had to create a new table and now it is working fine. Thanks again everyone. I would lost with out your hard work replying to all these post.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2016, 12:34 PM
  2. Run-Time Error 3061
    By lefty2cox in forum Programming
    Replies: 7
    Last Post: 02-21-2016, 07:33 AM
  3. Run-time error '3061'
    By TheLazyEngineer in forum Programming
    Replies: 1
    Last Post: 03-04-2015, 11:17 AM
  4. VBA Code Returning Error Run Time Error 3061
    By tgwacker in forum Access
    Replies: 2
    Last Post: 11-24-2013, 11:00 AM
  5. Error 3061
    By Shanks in forum Queries
    Replies: 4
    Last Post: 09-16-2009, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums