# How to use DoCmd to open a form 5.0.2.4

5.2.0.4 Being new to this and coming from MSAccess I was able to do light weight programming in access. Trying to figure out the basics I want to just open a form from a push button using a macro and the DoCmd feature. I have not been able to find simple examples of how to do this. I tried the Access2Base tutorial, openoffice forum and several sample DB's. I just can't find how to do it. Everything I've tried generates errors like this As you can see by my REM'd lines, Ive tried several ways with no results. I've crashed Base so many times I'm tired of having to reboot. I know this sounds basic but the irony is not escaping me....Thanks

edit retag close merge delete

I'm beginning to think I have bigger problems. I can't even run an Access2Base Public Function. Follow link tp a dropbox of a PDF with screen shots. Is there something missing in my configuration ?

( 2016-08-22 03:16:04 +0100 )edit

I suspect there is something lacking in the calls to the Access2Base library. Have you applied what is described in HERE ? Especially the initial call to OpenConnection() to get things right when the database file gets opened (read "Start using the library")?

JPL

( 2016-08-22 13:23:45 +0100 )edit

JPL, I've read this but am confused. I see all the Access2Basic libraries in the macro organizer. 1. Are you saying I have to enter the open connection code described in every macro I write. 2. When I open the TT Northwind DB(Access2Basic tutorial) I get an exception error. I remember having to point to the hsqldb file to use for that DB but I can't remember where I found how to do it. My head hurts!

( 2016-08-22 13:49:34 +0100 )edit

I checked the connections via options and they are all grayed out. Here is a link to the screen shot.

( 2016-08-22 14:26:58 +0100 )edit

JPL.Won't let me edit my other comment. I associated the open/close connections on the events tab and now they appear even on a new DB. I guess that solves the using Access2Base code. Do I need to embed similar references in each DB I create?The code example given above does not look like Access2Dase. Looks like the code used before Access2Base. Is there something I need to do to make that code work? To use the tutorial I also had to add a pointer to the TT Northwind jar file.

( 2016-08-22 15:43:10 +0100 )edit

As I said, I added the open connections code to the events tab and it worked. After a re-boot they don't work. Access2Base has an init library with a dbopen and no errors, but, when I try to edit to look at it I get a variable null error ???

( 2016-08-22 16:45:09 +0100 )edit

Sort by » oldest newest most voted

The correct syntax for opening a Form is -

oForm = ThisDatabaseDocument.FormDocuments.getByName(“Formname”)
oForm.Open


You have shown that you have tried this. The problem may be in your use of Formname. The name here is not the name of the Form as it appears in the Forms Tab of the GUI.

Open that Form in edit mode and click on Form Navigator. This will show under Forms the Form Name and this is the Name required in getBtName in the macro. If you have created your Forms using the Form Wizard all Forms created will have the same Name – MainForm. If you create them using Design View they will have the Name Form1. This is one of the odd quirks of Base. It is not a problem if you do not have a need to refer to the Form by its Name. It is a good idea to change the Names to the same value as they appear in the Forms Tab of the GUI. If you have more than one Form which will all have the default Name of MainForm there will be a conflict if you need to refer to these Forms by Name.

more

Answered, I've given this a try. Renamed my Form to match as shown under forms. Tried it. Crashed! Corrupted DB to the point I had to use task manager to close it, several times. Starting over from scratch. Uninstall LO, clear cash, repair registry(Ccleaner). Remove LO directories left behind, etc... Starting over from scratch ! May take a day or so... I'll get back. This time I'm going to use Wizard driven tables, forms and see what happens.

( 2016-08-22 12:19:00 +0100 )edit

I am going to mark this as answered to get it off the list. Ratslinger provided an example that works and has pointed me in the right direction.

( 2016-08-26 12:40:24 +0100 )edit