form activate disabled?

G

Guest

Hi,
I have a Form that launch a different form (modal). When the user is
done adding a new record, it supposingly pass back the new name thru a global
var. A txtbox on the original form is updated during the OnActivate event.
However, that does seem to work, the on activate event does not launch after
the different form is closed (and even the original form is set on focus).
Any idea?
Also, my modal form doesn't respond to any shortcut key (e.g. Ctrl+w to
close the form)...

Any help would be greatly appreciated.
Thx
 
R

Rick Brandt

Jeff said:
Hi,
I have a Form that launch a different form (modal). When the user
is done adding a new record, it supposingly pass back the new name
thru a global var. A txtbox on the original form is updated during
the OnActivate event. However, that does seem to work, the on
activate event does not launch after the different form is closed
(and even the original form is set on focus). Any idea?
Also, my modal form doesn't respond to any shortcut key (e.g.
Ctrl+w to close the form)...

Any help would be greatly appreciated.
Thx

Open the form with the acDialog argument of the OpenForm method. That will
cause the code to pause until the form that you just opened is either closed
or hidden. You can take advantage of that fact by grabbing the value of the
global variable on the very next line of code instead of trying to use an
event to figure out when the other form is closed.
 
G

Guest

Rick,
thx for replying.
the form is opened using acDialog. Yes, by setting it to modal, it
forces the user to close the form before they can do anything data entry.
however, it doesn't pause the program and go onto the next statement (i've
set break points to confirm that).
as the result i hv to do that on activity event on the form that starts the
other form. unfortunely, it doesn't trigger that event when the edit form
closes.
thx
 
R

Rick Brandt

Jeff said:
Rick,
thx for replying.
the form is opened using acDialog. Yes, by setting it to modal, it
forces the user to close the form before they can do anything data
entry. however, it doesn't pause the program and go onto the next
statement (i've set break points to confirm that).
as the result i hv to do that on activity event on the form that
starts the other form. unfortunely, it doesn't trigger that event
when the edit form closes.
thx

Post your code to open the form because something doesn't add up. Given the
code below...

DoCmd.OpenForm "SomeForm",,,,,acDialog
MsgBox "Test"

....the message box will definitely NOT be displayed until SomeForm is closed or
hidden. If your code is continuing before either of those happen then you are
either not using acDialog or something strange is happening.

This isn't a datasheet form is it? acDialog does not work on those. And you
have to be using the acDialog argument. Just making the form Modal does not
pause the calling code.
 
G

Guest

Rick,
Maybe I misunderstood your previous post. When I put the code
immediately after formOpen in the NotInList, the form opens as modal but the
next line of code continued on - as the result, the msgbox popped up.
When I put another msgbox on form Activate, it was never fired (except
when the form was loaded).
-----------------------------------------------------

Private Sub CmbRockName_NotInList(NewData As String, Response As Integer)

gsRockName = ""
Me.CmbRockName.Undo
Response = 0
OpenFormRocks
MsgBox "Right after sub OpenFormRocks"
' Response = 1

End Sub
--------------------------------------------------

Private Sub Form_Activate()

MsgBox "I m back"
If gbIsDirty Then
Me.CmbRockName.Requery
Else
gsRockName = ""
End If

Me.CmbRockName.Value = gsRockName
gbIsDirty = False

End Sub
-------------------------------------------------------
 
L

Larry Linson

Activate does not fire when you return from another form, such as your
dialog. You will have to find somewhere else to perform that function --
could be in the dialog's code, just after you issue the DoCmd.Close.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top