none
Disable Form Navigation Buttons But Show Record Count RRS feed

  • General discussion

  • Hello:

    I created special navigation buttons on a form for "Previous Record", "Next Record", "New Record" and "Delete Record".

    I need those buttons so I could do special processing for new records.

    To avoid confusions, I turned off the standard navigation buttons at the bottom of the form, which don't do any special processing. (I set the form's "Navigation Buttons" property to "No").

    However, I would like to see where I am in the table:  Record 5 of 50, etc.

    Can I add code to show the record number and total records, or can I modify the standard behavior of the built-in navigation buttons at the bottom of the form and turn back on the Navigation Buttons property?

    What is the best way to deal with this?

    Thanks,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    • Changed type RichLocus Saturday, December 21, 2019 2:09 AM I Found the Answer
    Saturday, December 21, 2019 1:33 AM

All replies

  • Hello:

    I started this as a question but found the answer.  Now this is a general discussion.

    I removed the built-in record navigation bar and replaced it with a new text box in the form.

    The following code is activated in In the Form_Current event:

    Me.txtRecordCounts = "Record " & Me.CurrentRecord & " of " & DCount("*", "tblBeerProductionBatches")

    Works well.



    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Saturday, December 21, 2019 2:12 AM
  • I removed the built-in record navigation bar and replaced it with a new text box in the form.

    Hi RichLocus,

    I wonder why you want to remove the built-in record navigation. I hardly use it, but in my opinion it does not harm either.

    In general I am interested in the total number of records in the form, but not so much in the current number. It just a temporary number, depending on selection and order criteria, and other way the records happen to be retrieved. It is just the sequence number in the current set.

    Where sequence numbers are important, as in classifications, then I will use a dedicated field for that.

    Perhaps you have cosmetic reasons to remove the built-in record navigation. Well, in that case you have already found the solution.

    Next question is, do you want to have this implemented on all your forms, or just on a few? I know, it is my pet subject. With generalized forms it is only a "one-line" modification to have it where you want.

    Imb.

    Saturday, December 21, 2019 9:36 AM
  • Rather than calling the DCount function, you can do it more efficiently be means of the Count operator:

        ="Record " & [Form].[CurrentRecord] & " of " & Count(*)

    or, if you wish to replicate the behaviour of the built in navigation bar, and show the count +1 when on an empty or unsaved new record:

        ="Record " & [Form].[CurrentRecord] & " of " & Count(*)+IIf([Form].[NewRecord],1,0)

    In each case make the expression the ContolSource property of an unbound text box.


    Ken Sheridan, Stafford, England


    • Edited by Ken Sheridan Saturday, December 21, 2019 11:39 AM
    Saturday, December 21, 2019 11:23 AM
  • Hello:

    Thanks for your response.  I had to remove the normal navigation buttons because when a user uses the built-in "next record" widget, it will create a new record instead of stopping at the last record.  That raised havoc with my logic.

    So, I changed the code to detect a new record and issued an Undo.  I had to do that because on a new record I had code that actually created a new record by inserting a customer key.

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Monday, December 23, 2019 11:49 PM
  • Ken:

    Thanks!  Good to know.

    Rich


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Monday, December 23, 2019 11:50 PM
  •  I had to remove the normal navigation buttons because when a user uses the built-in "next record" widget, it will create a new record instead of stopping at the last record.  That raised havoc with my logic.

    Hi Rich,

    Yes, now I see your problem. I have never encounterd that problem, because in overview forms I never use the possibility to enter new records.

    New records are entered through a special(ized) "New" form, available through a "New" button on any Overview-form. In this "New" form all checks are handled regarding a new record. Known values are filled in, formatting is done, relations can be made with other entities, checks for conditions, checks for key violations, etc.

    Imb.

    Tuesday, December 24, 2019 10:42 AM
  • I had to remove the normal navigation buttons because when a user uses the built-in "next record" widget, it will create a new record instead of stopping at the last record.  That raised havoc with my logic.

    So, I changed the code to detect a new record and issued an Undo.  I had to do that because on a new record I had code that actually created a new record by inserting a customer key.

    If you assign a value to the DefaultValue property of the bound control rather than to is Value property (which is the default property of the control) a new record will not be initiated until further data is inserted by the user or in code.  The need to undo the record is thus obviated, and moving to another record  or closing the form will be sufficient.

    Another option would be to set the form's AllowAdditions property to False (No), and allow the insertion of a new record by other means, e.g. via unbound controls in the header or footer, by opening a separate form whose DataEntry property is True in dialogue mode, and then requerying the current form,  or by embedding the current form as a subform in another bound form whose DataEntry property is True, with bound controls in the parent form, and a means to save the current record in the parent form and requery the subform to show the newly inserted record.

    You'll find an example of the last approach in Fee.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to amend the form design accordingly.  

    If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

    In this little demo file the fee transactions form includes a subform, and bound controls in the parent form to insert a new transaction, along with a button to update the subfrom with the newly inserted record.  In my case the subform is not manually updatable, but it could equally well be so.


    Ken Sheridan, Stafford, England

    Tuesday, December 24, 2019 1:42 PM
  • Thanks Ken for the examples.  Hope all is well in England.  Things here in the U.S. are not so great with our government.

    Regards,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Wednesday, December 25, 2019 5:03 PM
  • Hope all is well in England.  Things here in the U.S. are not so great with our government. 

    Not good here, I'm afraid, with the clown we have for a Prime Minister.  In the US you at least have constitutional checks on the power of the executive.  We don't even have a written constitution, just an antiquated and unrepresentative parliamentary system in which the executive and legislature are in reality one and the same.  Even the rule of law is under threat, with Johnson proposing to drastically reduce the oversight which the judiciary is able to execute over the government.

    As the Chinese say, 'We live in interesting times'.


    Ken Sheridan, Stafford, England

    Thursday, December 26, 2019 10:55 AM