Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    disabling new record button

    Hi everyone,



    How do I disable the button which creates a new record in a form?


    Click image for larger version. 

Name:	Capture.PNG 
Views:	23 
Size:	3.5 KB 
ID:	38034
    Because I already have a button which has the same function and is written by code. And my coworkers use the record selector to move through the form.

    Thank you in advance.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Set Allow Additions = No in the form property sheet.
    If you wish you can also set Navigation Buttons =No to hide everything in your screenshot
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you for your reply.

    it works but when I go for a new record using my button an error comes up in my code:
    Code:
    Private Sub agregarRegistro_Click()
    
    Me.Undo
    If MsgBox("¿Quieres agregar un nuevo registro?", vbQuestion + vbYesNo, "Pregunta") = vbYes Then
    End If
    DoCmd.GoToRecord , , acNewRec
    Me.cmdMandarCorreo.Enabled = False
    End Sub
    How do I solve this?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    It creates an error because the code I supplied disabled adding new records as requested
    Your if...end if code does nothing.
    Move End if to the last line
    Before the new record line add me.AllowAddtions=True

    But what is the point of disabling it just to re-enable it?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Hi, it works for the first time but it appears again when a second record is introduced. I have written in the code on Form_Current: "Me.AllowAdditions = False". However the same error as I mentioned before comes up.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    In your previous question, you asked how to allow new records again. I gave you an answer. You appear to have done the opposite.

    You say the same error occurs but have never said what that error is.

    It really isn't clear to me what you want to do and why. Nor what your issue is.
    Perhaps someone else will be able to assist if you explain your issue clearly and in full.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    I think you want to do away with this entire navigation display at the bottom of the form by setting Navigation Buttons = NO.
    Then provide your own customized First, Next, Prior, Last buttons as well as your current New Record button.


  8. #8
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Yes, It could be a solution for my problem. But, is there a possibility of recreation the record counting?

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    If you mean can you create your own navigation controls to replace the built in Access navigation bar, the answer is yes e.g.
    Click image for larger version. 

Name:	Capture.PNG 
Views:	15 
Size:	3.1 KB 
ID:	38101

    NOTE: I also have a separate 'New' button elsewhere on the same form

    Its not difficult to do ...if you think its worth the time needed to create it
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #10
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Yes! that´s what I want. Could you provide me an example, please?

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Create 4 buttons: cmdFirst, cmdNext, cmdPrev, cmdLast
    Use code similar to that in the attached text file for those buttons

    You also need a label for the record counter - mine is called lblPos.
    The code to update that is part of the Form_Current event
    I've included code for that in the text file

    Adapt as necessary

    Hope that helps
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you so much for your reply!

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    You're welcome. Hopefully the code will make sense as is.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #14
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Oh, sorry but Access does not recognize (maybe because it is in spanish) in my code the following part:

    Me.lblPos.Caption = Me.CurrentRecord & " of " & N

    Writing this line with this structure seems like it does not work.'

    Any idea?

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    The record counter lblPos needs to be a LABEL. You have probably used a textbox
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Disabling The Close Button
    By Eranka in forum Access
    Replies: 3
    Last Post: 01-23-2018, 07:51 AM
  2. Replies: 2
    Last Post: 02-22-2016, 02:49 PM
  3. Replies: 4
    Last Post: 11-11-2013, 08:39 AM
  4. disabling an enabled button that has been clicked.
    By aaron47 in forum Programming
    Replies: 3
    Last Post: 08-26-2011, 09:49 AM
  5. Disabling A Button
    By cksm4 in forum Programming
    Replies: 8
    Last Post: 10-05-2010, 02:07 PM

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