How to use DoCmd to open a form
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

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 ?

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, 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!

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

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.

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 ???

The correct syntax for opening a Form is -

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

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.

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.

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.