Set name of the active form as a variable

  • Thread starter Thread starter cbgraham_asu
  • Start date Start date
C

cbgraham_asu

I have a custom switchboard. I want it to open a new menu and THEN
close the previous menu, so that the screen doesn't blink in between.
Here's the code I keep trying to tweak but which never works.

Const conCmdGotoMenu = 1
Dim stfrm As String

(...some in between stuff that works fine)

' Go to Menu

Case conCmdGotoMenu
Set stfrm = Me.Form
DoCmd.OpenForm rs![Argument]
DoCmd.Close acForm, "stfrm"

My problem is that "Set stfrm = me.form" doesn't work. Nothing else
I try does either. I'm at a loss. So how do I set the name of the
active form as a variable? This has to work as part of a public
function so that it can be called from various forms and work. I
could just do...

docmd.Close
Docmd.openform rs![Argument]

.....and it works okay, but the blink "annoys people." =S And now i
have to solve it just for the principal of the matter. Many Thanks!
 
I think you are doing it the hard way. Post the content of your Switchbord
Items table.
 
Its not the just built in switchboard because the layout wouldn't
work. The main menu and submenus need to have different arrangements
and different buttons - so they are actually different forms. The
code is the same as for the switchboard, but there's no switchboard ID
on the switchboard items table b/c it's irrelevant. Here's the items
table.

ItemNo ItemText Command Argument
1 MENU - Main 1 MenuMain
2 MENU - Special reports 1 MenuReports
3 SEND FEEDBACK 2 FrmSuggestions
4 HELP 3 FrmHelp
5 EXIT 6
6 STATUS Open Orders 3 FrmOrders
7 STATUS Unpaid Invoices 3 FrmInvoices
8 RUN Open Order Report 4 RptOpenOrders
9 RUN Unpaid Invoice Report 4 RptInvoices
10 EXPORT Open Orders 3 FrmRPOrders
11 EXPORT Invoices 3 FrmRPInvoices
........etc......
 
I have a custom switchboard. I want it to open a new menu and THEN
close the previous menu, so that the screen doesn't blink in between.
Here's the code I keep trying to tweak but which never works.

Const conCmdGotoMenu = 1
Dim stfrm As String

(...some in between stuff that works fine)

' Go to Menu

Case conCmdGotoMenu
Set stfrm = Me.Form
DoCmd.OpenForm rs![Argument]
DoCmd.Close acForm, "stfrm"

My problem is that "Set stfrm = me.form" doesn't work. Nothing else
I try does either. I'm at a loss. So how do I set the name of the
active form as a variable? This has to work as part of a public
function so that it can be called from various forms and work. I
could just do...

docmd.Close
Docmd.openform rs![Argument]

....and it works okay, but the blink "annoys people." =S And now i
have to solve it just for the principal of the matter. Many Thanks!

Instead of:

Case conCmdGotoMenu
Set stfrm = Me.Form
DoCmd.OpenForm rs![Argument]
DoCmd.Close acForm, "stfrm"

Try:

Case conCmdGotoMenu
stfrm = Me.Name
DoCmd.OpenForm rs![Argument]
DoCmd.Close acForm, stfrm

Note that it might be worthwhile to experiment with various slight
delays between the OpenForm and Close.

James A. Fortune
(e-mail address removed)
 
Back
Top