Form opens if blank?

cocoonfx

cocoonfx
Local time
Today, 01:52
Joined
Oct 13, 2005
Messages
62
Hello I am creating a DB which needs to have a particular table filled in before you can proceed. For example when the database is opened for the first time the user must enter in some information about themselves like and address etc.. before they can go to the next part of the database.

The table is called "yourdetails"?
 
How about trying this

1. Create a new form in design view, completely blank doesn't need anything of it. In the code of the OnLoad event or OnCurrent event, do :
Dim lookup as string
lookup = DLookup("[Field name]","table name","[when this field name] = value")

If (IsNull(lookup)) Then
DoCmd.OpenForm "form name to enter details"
DoCmd.Close acForm, "this forms name"
Else
DoCmd.OpenForm "form name when there are details"
DoCmd.Close acForm, "this forms name"
End If

2. Create an AutoExec Macro that loads the form on startup, but the view of that form is HIDDEN! This way the user will never see it.

3. Tell the macro to run on startup of the database (which should then load the blank form but you won't see it) which will then check the table to see if there has been any data entered. If there has been data entered into the form then it will load whatever form you specify, but if there is nothing in the table for the specified record (just use ID 1 or whatever the first record will be) it will load the form to insert the data.

Hopefully this code has helped in some way, if not then put the database on here and i'll take a look at it.

The above code may be very inaccurate, i was unable to check the correct format at the time of writing this, but hopefully it'll give you a rough idea of what to do. Sorry if i've misunderstood what you were aiming to do.
 
Err..

A muich simpler way is to require the field in Table Design view (set Required to Yes). You can also set the Validation Rule to "Is Not Null". The Validation Text is the message that will be displayed if they try to leave the field blank.
 

Users who are viewing this thread

Back
Top Bottom