Results 1 to 6 of 6
  1. #1
    MikeDB is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    3

    Arrow P1 Deleting records -'Run-time error 3201' keeps appearing and P2 Enabling Combo Box problem

    Hi all!

    I'm not an IT professional but an enthusiastic amateur, sixteen years ago I studied part-time courses at my local collage covering Excel and Access (Level 3) but I've not practiced Access for some fourteen years, I'm just getting back into building a few apps mainly for friends and family. I'm using Access 2007/Windows 7 and I'm hoping someone could help me with a couple problems:

    P1) I have a command button to delete records from a sub form named (Utilities Sumary), code:

    Private Sub Delete_Data__Utilities__Click()
    Me.Utilities_Sumary.Form.Recordset.Delete
    Me.Utilities_Sumary.Form.Recordset.MoveNext
    End Sub



    It all works Ok until you come to a 'user' test and when you press the button with no records in the sub form the user receives a ("Run-time error '3201' No current record), - What could I use to stop this Run-time error appearing?

    P2) I have 2 x combo boxes one named 'Pmt Schedule' in which the Data Properties I have set Enabled to 'No', the second combo box named 'How is this paid?' contains text - 'Monthly', 'Quarterly' and 'Yearly', the objective is to enable 'Pmt Schedule' only when - Yearly is selected! I've tried numerous permutations in - Private Sub How_is_this_paid__AfterUpdate() but to no avail!

    Many thanks any help.

    Mike

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For the first, try trapping for that error:

    http://www.baldyweb.com/ErrorTrap.htm

    For the second:

    http://www.baldyweb.com/ConditionalVisibility.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    P1 - use error trapping. After your declarations (Dim statements) I put
    On Error GoTo errHandler
    You need a line label by that name and a way to exit before the handler if no errors are generated.

    ExitHere: 'at the end of the form code but before the error handling block
    Exit Sub 'or function

    errHandler:
    If Err.Number = 3201 Then 'can't see your code so I can't advise on what needs to happen. Could be one of the following:
    Exit Sub
    Resume Next
    Resume exitHere
    Else
    Msgbox "Error " & Err.Number & ": " & Err.Description
    Resume exitHere
    End If

    P2 should be something like
    Code:
    Private Sub How_is_this_paid_AfterUpdate()
     If Me.How_is_this_paid = "Yearly" Then Me.[Pmt Schedule].Enabled = True
    End If
    You should research naming conventions. Spaces and special characters should not be in names (I don't even use the acceptable underscore).
    https://access-programmers.co.uk/for...d.php?t=225837
    or
    http://access.mvps.org/access/general/gen0012.htm
    http://allenbrowne.com/AppIssueBadWord.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    MikeDB is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    3
    Many thanks for the links!

  5. #5
    MikeDB is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    3
    Hi Micron

    Many thanks for your reply. Regarding P1, I tried all that you suggested but still couldn't get rid of the Run-time error 3201, I'm probably bit out of my depth with error handling as my knowledge of coding is minor! The initial code I put in works Ok every time I hit my delete button, it does remove the records line by line with no problem, only when you carry out the 'idiot' test with no records and hit delete does the error appear, I'll have to rethink on that one!

    P2 You used the same code that I did, apart from the square parenthesis it was identical, it should have worked but it didn't, well these things are sent to try us so I'm going to redesign the form.

    Once again many thanks for your time and interest.

    Mike

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    post the code for P1?
    P.S. you need the brackets because you put spaces in your control name. By now, hopefully you have read up on why these and special characters (save for the underscore) should be avoided. This rule applies to every name in an Access app (and come to think of it, any program language I've ever dabbled in). I follow the same rule for network folders as well.

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

Similar Threads

  1. Replies: 7
    Last Post: 04-07-2017, 02:08 AM
  2. Error Handeling for a 3201 and 3022 Error
    By starlancer805 in forum Access
    Replies: 3
    Last Post: 03-11-2015, 12:46 PM
  3. Replies: 6
    Last Post: 10-07-2014, 03:02 PM
  4. Error 3201 on Form / Subform
    By jerem in forum Programming
    Replies: 2
    Last Post: 12-01-2012, 12:34 AM
  5. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 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