From: Owl on
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" <Owl(a)discussions.microsoft.com> wrote in message
> news:C2C741DC-54FC-4007-8B46-D58200BF011F(a)microsoft.com...
> > 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" <Owl(a)discussions.microsoft.com> wrote in message
> >> > news:127C35AB-50A5-455A-B803-BA6EE2D8A9ED(a)microsoft.com...
> >> > > 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)
> >> >
> >> > .
> >> >
>
>
> .
>
From: Douglas J. Steele on
Hmm. I just revisited that thread (at
http://groups.google.com/group/microsoft.public.access/browse_thread/thread/6b8fcf808197c849/e2b67d49bcd16996?q=group:microsoft.public.access+insubject:puzzling+insubject: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" <Owl(a)discussions.microsoft.com> wrote in message
news:26F6F16B-FD77-42C6-9C6B-56758DB03AB1(a)microsoft.com...
> 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.
>


From: Dirk Goldgar on
"Owl" <Owl(a)discussions.microsoft.com> wrote in message
news:EDAA51F2-C9CB-411D-A219-D21550E5F79C(a)microsoft.com...
>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)

From: Owl on
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" <Owl(a)discussions.microsoft.com> wrote in message
> news:EDAA51F2-C9CB-411D-A219-D21550E5F79C(a)microsoft.com...
> >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)
>
From: Dirk Goldgar on
"Owl" <Owl(a)discussions.microsoft.com> wrote in message
news:FE6FB844-60A6-4B9A-9C9A-C4CE62C7D50E(a)microsoft.com...
> 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)