Open to null

  • Thread starter Thread starter alex
  • Start date Start date
A

alex

Does anyone have some advice/trick on getting a Form to open with
nothing in its controls/fields?

I have Form based on a Table. The Form has a combo box to look up
records.

I would like the Form to open without a record in it; when the user
selects a record ID from the drop-down-list, a record then appears.

Thanks,

alex
 
Hi Alex

Open the form in Design View
Right click the grey area (outside the detail where the controls are)
Open the Property Box
Select Data column
Select Data Entry
Select = Yes
Save

Now when the form opens it will open to a new record.
 
hi Alex,
Does anyone have some advice/trick on getting a Form to open with
nothing in its controls/fields?
Use a condition like

SELECT * FROM [yourTable] WHERE 0 = 1

in the RecordSource.



mfG
--> stefan <--
 
If you make the subform a child of the dropdown field on you main
form, then there will be NO record showing unless there is a name/
whatever selected in the dropdown.

You will have to add the child/ master field names to the subform
manually since the wizard cannot figure out what to relate since the
main form isn't based on a data source. Just write in the field names
in [] and it should work fine.

Ron
 
Hi Stefan

You could use a simply "ApplyFilter" to set critera that can't be met so you
will get the form but no records. Something like this (onOpen)

Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "FieldName = null"
End Sub

Change fieldname to your primary field (I assume it's a number or autonumber)

Have fun

--
Wayne
Manchester, England.



Stefan Hoffmann said:
hi Alex,
Does anyone have some advice/trick on getting a Form to open with
nothing in its controls/fields?
Use a condition like

SELECT * FROM [yourTable] WHERE 0 = 1

in the RecordSource.



mfG
--> stefan <--
 
Hi Stefan

You could use a simply "ApplyFilter" to set critera that can't be met so you
will get the form but no records. Something like this (onOpen)

Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "FieldName = null"
End Sub

Change fieldname to your primary field (I assume it's a number or autonumber)

Have fun

--
Wayne
Manchester, England.



Stefan Hoffmann said:
Use a condition like
SELECT * FROM [yourTable] WHERE 0 = 1
in the RecordSource.
mfG
--> stefan <--- Hide quoted text -

- Show quoted text -

Thanks Wayne et al for the help...
When I try the DoCmd, I'm getting the following run-time error:
'You entered an expression that has no value.'

My primary field is EMPID
I typed DoCmd.ApplyFilter, [EMPID] = NULL
I've also tried it a number of different ways?

alex
 
Hi Stefan
You could use a simply "ApplyFilter" to set critera that can't be met so you
will get the form but no records. Something like this (onOpen)
Private Sub Form_Open(Cancel As Integer)
DoCmd.ApplyFilter , "FieldName = null"
End Sub
Change fieldname to your primary field (I assume it's a number or autonumber)
Stefan Hoffmann said:
hi Alex,
alex wrote:
Does anyone have some advice/trick on getting a Form to open with
nothing in its controls/fields?
Use a condition like
SELECT * FROM [yourTable] WHERE 0 = 1
in the RecordSource.
mfG
--> stefan <--- Hide quoted text -
- Show quoted text -

Thanks Wayne et al for the help...
When I try the DoCmd, I'm getting the following run-time error:
'You entered an expression that has no value.'

My primary field is EMPID
I typed DoCmd.ApplyFilter, [EMPID] = NULL
I've also tried it a number of different ways?

alex- Hide quoted text -

- Show quoted text -

I've now used DoCmd.ApplyFilter, "EMPID = NULL" and am not getting an
error, but also not seeing the Form as well.
It appears that the filter is not finding the record then the Form is
not displaying on the screen
 
Does anyone have some advice/trick on getting a Form to open with
nothing in its controls/fields?

I have Form based on a Table. The Form has a combo box to look up
records.

I would like the Form to open without a record in it; when the user
selects a record ID from the drop-down-list, a record then appears.

Thanks,

alex

As an alternative that might work for you try putting the following code in
the Form's Open event:

Private Sub Form_Open(Cancel as Integer)
DoCmd.GoToRecord acDataForm, Me.Name, acNewRecord
End Sub

John W. Vinson [MVP]
 
Back
Top