Re: AddNew button on the Record selector



Hi again, Marsh,
I found out something interesting. I tried this code from the help file to
list all open forms and, for each one, all the controls they hold:
' ***********************************
Dim frm As Form, ctl As Control
Dim intNbFrm As Integer
intNbFrm = Forms.Count
MsgBox "There is actually " & intNbFrm & " from(s) open."
' List the Forms collection.
For Each frm In Forms
' Print the name of the form.
Debug.Print "Form name: "; frm.Name
' List the Controls collection for each form.
For Each ctl In frm.Controls
' Print the name of each control.
Debug.Print "Control name >>> "; ctl.Name
Next ctl
Next frm
' ***********************************
That code shows that there is only one form open and that the subform it
holds is considered to be a control. That is why I cannot access it as a from.
What can I do now with that control? Can I still go to it's last record or
use methods or properties that apply to forms?
Thanks again.
--
Jac Tremblay


"Marshall Barton" wrote:

> Jac Tremblay wrote:
> >On my form, I had to create a personalized AddNew button because I need some
> >special calculations to be done when that event happens.
> >I need the record selector to be displayed for the user to navigate between
> >records (First, Previous, Next and Last).
> >But the record selector has an AddNew button also that does not do the same
> >thing as my personalized one. And that causes me a problem.
> >I would like to keep the record selector but disable the AddNew button or
> >get the button to run the procedure I wrote for the AddNew record.
>
>
> It sounds like you are talking about the Navigation buttons
> at the bottom of the form, not the Record Selector button at
> the left of each record.
>
> The New Record navigation button just takes you to a new
> record, it doesn't create a new record. That happens when
> the record is saved by navigating to a different record or
> several other actions.
>
> You can run your own procedure to set values in a new record
> by putting your code in the Form's Current event procedure:
>
> If Me.NewRecord Then
> ' your code
> End If
>
> without creating your own button or trying to fudge the
> navigation buttons.
>
> Note that if a user accidently navigates to a new record and
> your code sets the value of some bound controls, the user
> needs to hit the Esc key twice (to back out of the changes
> you made) before navigating to a different record.
>
> --
> Marsh
> MVP [MS Access]
>
.