A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Quit macro not working in runtime



 
 
Thread Tools Display Modes
  #11  
Old May 25th, 2010, 05:25 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Quit macro not working in runtime

Don't waste any time trying to get it to work.

Microsoft's web interface to these newsgroups has never really worked
properly, so even if you managed to get it working today, there's no
guarantee it'll work tomorrow.

And the fact that Microsoft is dropping these newsgroups in favour of new
web-based forums makes it even more futile to worry about it! g

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"Owl" wrote in message
...
It didn't help. I am still not getting email notifications. Does anyone
know what I can do?

Thanks for any help.

"Owl" wrote:


Sorry, sorry, me again. I may have sorted out the minor Notify me of
replies. I have just seen the little icon in the bottom right corner
that
allowed me to enable Notification. Presumably that will work now. I am
really sorry if you spent any time helping me with that before you see
this.

Looking forward to help on the other problem, though - my Quit macro.


"Dirk Goldgar" wrote:

"Owl" wrote in message
...
This is the very first time I am using Runtime. I am using Runtime
2007
and
my Quit macro isn't working. What can I do about it?

Thanks for any replies.


What exactly are the actions in your Quit macro?

When you say "isn't working", what exactly do you mean? Do you get an
error
message, or does nothing at all happen when you run it? How is the
macro
invoked?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

.



  #12  
Old May 25th, 2010, 07:56 PM posted to microsoft.public.access
owl
external usenet poster
 
Posts: 128
Default Quit macro not working in runtime

Thank you for saving me a lot of time, Douglas. I actually put in a separate
question for this just before I found your reply.

I can hardly type I am laughing so much - I don't know if you will remember
this - but Wayne-I-M started a thread with the subject of Puzzling Americans
on 22/12/2006. Your response was brilliant and funny, but so was the whole
conversation, except Wayne's question which was a perfectly valid question,
but the seriousness - except for your response and those of one or two others
- of the conversation had me in stitches and still does. I put in a response
(to your response) about how my fellow South Africans would view it, if you
are interested to read it - well it is there, even if you aren't interested
to read it. Smiles.

"Douglas J. Steele" wrote:

Don't waste any time trying to get it to work.

Microsoft's web interface to these newsgroups has never really worked
properly, so even if you managed to get it working today, there's no
guarantee it'll work tomorrow.

And the fact that Microsoft is dropping these newsgroups in favour of new
web-based forums makes it even more futile to worry about it! g

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"Owl" wrote in message
...
It didn't help. I am still not getting email notifications. Does anyone
know what I can do?

Thanks for any help.

"Owl" wrote:


Sorry, sorry, me again. I may have sorted out the minor Notify me of
replies. I have just seen the little icon in the bottom right corner
that
allowed me to enable Notification. Presumably that will work now. I am
really sorry if you spent any time helping me with that before you see
this.

Looking forward to help on the other problem, though - my Quit macro.


"Dirk Goldgar" wrote:

"Owl" wrote in message
...
This is the very first time I am using Runtime. I am using Runtime
2007
and
my Quit macro isn't working. What can I do about it?

Thanks for any replies.


What exactly are the actions in your Quit macro?

When you say "isn't working", what exactly do you mean? Do you get an
error
message, or does nothing at all happen when you run it? How is the
macro
invoked?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

.



.

  #13  
Old May 25th, 2010, 08:15 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Quit macro not working in runtime

Hmm. I just revisited that thread (at
http://groups.google.com/group/micro...ject:americans )
, but nothing there jumps out as being specifically related to South Africa.

I hadn't realized it had raised such a discussion!

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"Owl" wrote in message
...
Thank you for saving me a lot of time, Douglas. I actually put in a
separate
question for this just before I found your reply.

I can hardly type I am laughing so much - I don't know if you will
remember
this - but Wayne-I-M started a thread with the subject of Puzzling
Americans
on 22/12/2006. Your response was brilliant and funny, but so was the
whole
conversation, except Wayne's question which was a perfectly valid
question,
but the seriousness - except for your response and those of one or two
others
- of the conversation had me in stitches and still does. I put in a
response
(to your response) about how my fellow South Africans would view it, if
you
are interested to read it - well it is there, even if you aren't
interested
to read it. Smiles.



  #14  
Old May 26th, 2010, 12:04 PM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Quit macro not working in runtime

"Owl" wrote in message
...
I did what you asked and opened the database with
no other objects open except a simple unbound form that has only a button
that invokes your Quit macro. It worked. However, I need the macro to
run
from the switchboard.



That strongly suggests that there is something going on, possibly in your
switchboard form, possibly in some other code that is invoked by your
switchboard or by an autoexec macro, that is causing the difficulty. What
is the nature of your switchboard form? Is it the same sort of switchboard
that is constructed by the Access switchboard wizard? Have you modified the
code behind it? You may need to post the code.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #15  
Old May 27th, 2010, 10:55 PM posted to microsoft.public.access
owl
external usenet poster
 
Posts: 128
Default Quit macro not working in runtime

Thanks, Dirk. Here is the code for my Switchboard. Yes, I fiddled with it
here and there, but I think it is back to what it was before (or at least,
more or less), except for the WarningsOn on Close.

Option Compare Database

Private Sub Form_Close()
DoCmd.SetWarnings (WarningsOn)

End Sub

Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True

End Sub

Private Sub Form_Current()
' Update the caption and fill in the list of options.

Me.Caption = Nz(Me![ItemText], "")
FillOptions

End Sub

Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM [Switchboard Items]"
stSql = stSql & " WHERE [ItemNumber] 0 AND [SwitchboardID]=" &
Me![SwitchboardID]
stSql = stSql & " ORDER BY [ItemNumber];"
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rs.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard
page"
Else
While (Not (rs.EOF))
Me("Option" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Visible = True
Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText]
rs.MoveNext
Wend
End If

' Close the recordset and the database.
rs.Close
Set rs = Nothing
Set con = Nothing

End Sub

Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.

' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
Const conCmdOpenPage = 9

' An error that is special cased.
Const conErrDoCmdCancelled = 2501

Dim con As Object
Dim rs As Object
Dim stSql As String

On Error GoTo HandleButtonClick_Err

' Find the item in the Switchboard Items table
' that corresponds to the button that was clicked.
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
stSql = "SELECT * FROM [Switchboard Items] "
stSql = stSql & "WHERE [SwitchboardID]=" & Me![SwitchboardID] & " AND
[ItemNumber]=" & intBtn
rs.Open stSql, con, 1 ' 1 = adOpenKeyset

' If no item matches, report the error and exit the function.
If (rs.EOF) Then
MsgBox "There was an error reading the Switchboard Items table."
rs.Close
Set rs = Nothing
Set con = Nothing
Exit Function
End If

Select Case rs![Command]

' Go to another switchboard.
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" &
rs![Argument]

' Open a form in Add mode.
Case conCmdOpenFormAdd
DoCmd.OpenForm rs![Argument], , , , acAdd

' Open a form.
Case conCmdOpenFormBrowse
DoCmd.OpenForm rs![Argument]

' Open a report.
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview

' Customize the Switchboard.
Case conCmdCustomizeSwitchboard
' Handle the case where the Switchboard Manager
' is not installed (e.g. Minimal Install).
On Error Resume Next
Application.Run "ACWZMAIN.sbm_Entry"
If (Err 0) Then MsgBox "Command not available."
On Error GoTo 0
' Update the form.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.Caption = Nz(Me![ItemText], "")
FillOptions


' Run a macro.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]

' Run code.
Case conCmdRunCode
Application.Run rs![Argument]

' Open a Data Access Page
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]

' Any other command is unrecognized.
Case Else
MsgBox "Unknown option."

End Select

' Close the recordset and the database.
rs.Close

HandleButtonClick_Exit:
On Error Resume Next
Set rs = Nothing
Set con = Nothing
Exit Function

HandleButtonClick_Err:
' If the action was cancelled by the user for
' some reason, don't display an error message.
' Instead, resume on the next line.
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox "There was an error executing the command.", vbCritical
Resume HandleButtonClick_Exit
End If

End Function


"Dirk Goldgar" wrote:

"Owl" wrote in message
...
I did what you asked and opened the database with
no other objects open except a simple unbound form that has only a button
that invokes your Quit macro. It worked. However, I need the macro to
run
from the switchboard.



That strongly suggests that there is something going on, possibly in your
switchboard form, possibly in some other code that is invoked by your
switchboard or by an autoexec macro, that is causing the difficulty. What
is the nature of your switchboard form? Is it the same sort of switchboard
that is constructed by the Access switchboard wizard? Have you modified the
code behind it? You may need to post the code.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #16  
Old May 31st, 2010, 04:13 AM posted to microsoft.public.access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Quit macro not working in runtime

"Owl" wrote in message
...
Thanks, Dirk. Here is the code for my Switchboard. Yes, I fiddled with
it
here and there, but I think it is back to what it was before (or at least,
more or less), except for the WarningsOn on Close.

Option Compare Database

Private Sub Form_Close()
DoCmd.SetWarnings (WarningsOn)

End Sub



That code is wrong, though, unless you have somewhere defined a global
variable named "WarningsOn". If your purpose is to turn warnings on, you
should write:


DoCmd.SetWarnings True

or

DoCmd.SetWarnings -1

However, if your switchboard is to remain open all the time the database is
open, I don't see any point in turning the warnings on while the database is
closing. I don't believe that command will have any effect when the
database reopens -- the warning settings at that time will be determined by
various option settings.

I have no idea whether the incorrect code in the Close event has any bearing
on your problem, I'm afraid.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.