OpenForm Method

DAS120202

New member
Local time
Today, 11:19
Joined
Dec 2, 2002
Messages
6
Hi,
I am trying to create a macro for a control button on my form to return it to the main switchboard. I have followed the original directions that I had, and it either says that I have a syntax or run-time error. The name is spelled correctly and I am using the format DoCmd.Openform "formname" Any idea what I am doing wrong. I can't get it to work for the life of me.

Thanks,
Ruth
 
Is your form's actual name "formname"? If so, double-check your form's name and make sure it's spelled correctly in the code.
If your form's not called "formname", then you need to replace "formname" in your code w/ the actual name of the form that you wish to open.
 
Thanks for the reply.
Sorry I wasn't more specific. My form name is Main Switchboard. I have been typing in DoCmd. OpenForm "Main Switchboard"
I have checked my spelling in both areas, and there isn't a problem there. Is there something I missed before, or am I writing the command wrong?
Thanks,
Ruth
 
Are you writing a macro? If so, I think you need to go about it differently. The code I gave you will work if put into VisualBasic.

I don't think you can use the submitted code in a macro. A maro should be easier to do though...

In the Action box select OpenForm
At the bottom, next to Form Name, select the Form from the drop-down box (it should be there!) If you're typing it in, leave the quotes off of the Main Switchboard.

If you're still having problems, the space between Main and Switchboard may be confusing. Try to eliminate the spaces from your names.

To find out how to reference the form, drop a button on your form. The wizard will guide you through creating a button that will open your form. From there you can look at the button's OnClick Event to see how the wizard has referenced your form.

HTH
 
Last edited:
Thanks for getting back to me. I looked over what you said and realize that I am working in Visual Basic. I have been working from a book on access, so I must have missed the fact that I was in visual basic. (Soory, this is the first data base that I have worked with in access).The code that you gave me is the same code that I found in the book, which is why I am confused that it isn't working. What I am trying to do over all is make sure that how ever my orders form is closed it will go back to the main switchboard. The book suggested that I take this route. Would a macro work better than visual basic?
Thanks so much for your help!
Ruth
 
You can set your Main Switchboard as the startup form which will open when you launch your program. To do so...

On the top menu>>Select Tools>>Startup...
In the right-hand column of the Startup menu>>where you see Display Form/Page>>select your Main Switchboard form from the list. This will open that form when you open the application. The user can close it though.

If you're a new to Access, macros make things easier. Macros cover many of the main functions in Access. Visual Basic will allow you to do everything a macro would and much more.

If you plan on using Access, I recommend getting used to VisualBasic. Like previously stated...Wizards will allow you to create buttons and then open the OnClick event to see the code. Then you can alter the code the way you want to.
 

Users who are viewing this thread

Back
Top Bottom