View Full Version : Open a particular form on first opening of a database.


Emma
11-06-2000, 07:26 AM
Hello!
Does anyone know how I can get a form to open on startup, if the value in a field in that form is null.

For example I have a form that should only ever open the very first time a database is opened, which the user must enter a name into a field. This information is then used in other parts of the database.

The next time they open the database, I just want it to show the normal menu screen.

I tried writing an autoexec macro, although I can get the form to open, this is every time the database is opened (and anyway I could do this though the startup options). When I tried putting a condition on the form it all went horribly wrong!

Any thoughts would be much appreciated!

Emma

Former
11-06-2000, 08:06 AM
Not the nicest way to do it, yet why don't you use the Startup Options to open the form. And then write a little bit of code on the Open_Form event of that form, which closes the form if the record in the database exists.

Talismanic
11-06-2000, 09:52 AM
Here is the code:


Private Sub Form_Open(Cancel As Integer)

If IsNull(Me.YourField) Then

DoCmd.OpenForm "YourFormName", acNormal

End If


End Sub

Emma
11-07-2000, 12:12 AM
Thanks to you both, your solution works well, and is alot nicer than the autoexec macro etc.

Emma