OnCurrent not triggered by return from another form

  • Thread starter Thread starter larry.nolan
  • Start date Start date
L

larry.nolan

(e-mail address removed)
Dec 4, 3:05 pm show options
Newsgroups: microsoft.public.access
From: (e-mail address removed) - Find messages by this author
Date: 4 Dec 2005 13:05:17 -0800
Local: Sun, Dec 4 2005 3:05 pm
Subject: OnCurrent not triggered by return from another form
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I'm debugging a Access97 d.b. that has been converted to Access 2002.
From form "Vol Info" I have a button that takes me to "Vol Hours" via
the Hours button and this procedure:
Private Sub GoToHours_Click()
DoCmd.Minimize
DoCmd.OpenForm "Vol Hours"
End Sub

When I return from "Vol Hours", I have this code that is executed
when I click on
the "Return" button:

Private Sub ReturnButton_Click()
DoCmd.Close , ""
DoCmd.OpenForm "Vol Info", acNormal, "", "", acEdit, acNormal
DoCmd.RunCommand acCmdRefresh
End Sub

the "Vol Info" form has a OnCurrent event property to execute a
procedure
Form_Current() but it is not executed when I return from "Vol Hours"
via the
ReturnButton_Click. The Form_Current() in "Vol Info" is executed
however when I click on one of the navigation buttons to go to the next
or previous record in my
bound "Vol Info" form.

I've verified that if I change my ReturnBUtton_Click() procedure as
shown below, I'll get back to "Vol Info" with the correct information
displayed:

Private Sub ReturnButton_Click()
DoCmd.Close , ""
DoCmd.OpenForm "Vol Info", acNormal, "", "", acEdit, acNormal
DoCmd.RunCommand acCmdRefresh
'next two calls are to correct the On Current problem in "Vol Info"
DoCmd.RunCommand acCmdRecordsGoToNext
DoCmd.RunCommand acCmdRecordsGoToPrevious

End Sub

Why isn't the OnCurrent event being triggered when I go through the
ReturnButton_Click() routine before my changes?

thanks,
Larry
 
(e-mail address removed)
Dec 4, 3:05 pm show options
Newsgroups: microsoft.public.access
From: (e-mail address removed) - Find messages by this author
Date: 4 Dec 2005 13:05:17 -0800
Local: Sun, Dec 4 2005 3:05 pm
Subject: OnCurrent not triggered by return from another form
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I'm debugging a Access97 d.b. that has been converted to Access 2002.

the Hours button and this procedure:
Private Sub GoToHours_Click()
DoCmd.Minimize
DoCmd.OpenForm "Vol Hours"
End Sub

When I return from "Vol Hours", I have this code that is executed
when I click on
the "Return" button:

Private Sub ReturnButton_Click()
DoCmd.Close , ""
DoCmd.OpenForm "Vol Info", acNormal, "", "", acEdit, acNormal
DoCmd.RunCommand acCmdRefresh
End Sub

the "Vol Info" form has a OnCurrent event property to execute a
procedure
Form_Current() but it is not executed when I return from "Vol Hours"
via the
ReturnButton_Click. The Form_Current() in "Vol Info" is executed
however when I click on one of the navigation buttons to go to the
next or previous record in my
bound "Vol Info" form.

I've verified that if I change my ReturnBUtton_Click() procedure as
shown below, I'll get back to "Vol Info" with the correct information
displayed:

Private Sub ReturnButton_Click()
DoCmd.Close , ""
DoCmd.OpenForm "Vol Info", acNormal, "", "", acEdit, acNormal
DoCmd.RunCommand acCmdRefresh
'next two calls are to correct the On Current problem in "Vol Info"
DoCmd.RunCommand acCmdRecordsGoToNext
DoCmd.RunCommand acCmdRecordsGoToPrevious

End Sub

Why isn't the OnCurrent event being triggered when I go through the
ReturnButton_Click() routine before my changes?

thanks,
Larry

Answered in microsoft.public.access .
 
The OnCurrent event only occurres when you move to a new record. Hence
it occurs when you move to the previous record or to the next, but not
when you've previously displayed the record and *NOT* moved to another.
To execute the OnCurrent event use

Call Form_[frmName].onCurrent

when you close the form that you're displaying.

I've only done that once or twice so I'm not certain about the syntax
100%, but that should do it.
 
David C. Holley said:
The OnCurrent event only occurres when you move to a new record. Hence
it occurs when you move to the previous record or to the next, but not
when you've previously displayed the record and *NOT* moved to
another. To execute the OnCurrent event use

Call Form_[frmName].onCurrent

when you close the form that you're displaying.

I've only done that once or twice so I'm not certain about the syntax
100%, but that should do it.

You're a bit off this time, David. First, there's no such thing as an
"OnCurrent" event. It's the Current event. There's an "OnCurrent"
property, which tells what to do when the Current event is raised. A
lot of people do refer to the events as the "OnThis" event or the
"OnThat" event, but it's usually a misnomer. There are only a few
events that are actually *named* "On<something>".

Second, the name of the event procedure for a form's Current event is
going to be "Form_Current". The form's name doesn't enter into it.
This would normally be a Private Sub, so you can't call it from outside
that form unless you change its Private attribute to Public.

Third, assuming you've changed the Sub to make it Public, you need to
qualify it with a reference to the form object itself. If the form is
open normally, you can do it like this:

Forms!NameOfForm.Form_Current
or
Call Forms("NameOfForm").Form_Current


Or, if you have, say, and object variable named "frm" that points to an
instance of the form, you could write

Call frm.Form_Current

You *can* also make a reference to the form's class module, and do it
like this:

Call Form_NameOfForm.FormCurrent

But that will open the form (hidden), if it isn't already open, which
may not be what you want. Also, if there are more than one instance of
the form open, you don't necessarily know which one of those instances
you're invoking. So I recommend you don't do it that way.
 
Ok so I was thinking of the PROPERTY not the EVENT and on top of that
too lazy to open up Access for the correct syntax.

Dirk said:
The OnCurrent event only occurres when you move to a new record. Hence
it occurs when you move to the previous record or to the next, but not
when you've previously displayed the record and *NOT* moved to
another. To execute the OnCurrent event use

Call Form_[frmName].onCurrent

when you close the form that you're displaying.

I've only done that once or twice so I'm not certain about the syntax
100%, but that should do it.


You're a bit off this time, David. First, there's no such thing as an
"OnCurrent" event. It's the Current event. There's an "OnCurrent"
property, which tells what to do when the Current event is raised. A
lot of people do refer to the events as the "OnThis" event or the
"OnThat" event, but it's usually a misnomer. There are only a few
events that are actually *named* "On<something>".

Second, the name of the event procedure for a form's Current event is
going to be "Form_Current". The form's name doesn't enter into it.
This would normally be a Private Sub, so you can't call it from outside
that form unless you change its Private attribute to Public.

Third, assuming you've changed the Sub to make it Public, you need to
qualify it with a reference to the form object itself. If the form is
open normally, you can do it like this:

Forms!NameOfForm.Form_Current
or
Call Forms("NameOfForm").Form_Current


Or, if you have, say, and object variable named "frm" that points to an
instance of the form, you could write

Call frm.Form_Current

You *can* also make a reference to the form's class module, and do it
like this:

Call Form_NameOfForm.FormCurrent

But that will open the form (hidden), if it isn't already open, which
may not be what you want. Also, if there are more than one instance of
the form open, you don't necessarily know which one of those instances
you're invoking. So I recommend you don't do it that way.
 
David C. Holley said:
Ok so I was thinking of the PROPERTY not the EVENT and on top of that
too lazy to open up Access for the correct syntax.

You can't sleep for a minute around here!
 
Back
Top