code to display for as continuous form

W

worksfire1

Is there code properties to set a form to displaying as a continous form? If
so, what is it? Thanks!!
 
F

fredg

Is there code properties to set a form to displaying as a continous form? If
so, what is it? Thanks!!

You can toggle between single form view and continuous form view.

Code a command button click event on that form's Header of Footer.:

DoCmd.OpenForm "FormName", acDesign
If Forms!frmContinuous.DefaultView = 0 Then
Forms!frmContinuous.DefaultView = 1
Else
Forms!frmContinuous.DefaultView = 0
End If
 
W

worksfire1

That doesn't work. When I click my button that opens this form, I receive an
error message stating that this property needs to be set in design mode. So,
I improvised and added a step in my openform procedure to open the form in
design mode, then set the defaultview as recommended in fred's post, then
open the form normal. Now I get an error message stating that this property
cannot be set.

Looking at Fred's solution, I don't understand how setting the default view
to true or false specifies exactly what view I want to open up. Some times I
want continuous form view and sometimes I want single form view.
 
F

fredg

That doesn't work. When I click my button that opens this form, I receive an
error message stating that this property needs to be set in design mode. So,
I improvised and added a step in my openform procedure to open the form in
design mode, then set the defaultview as recommended in fred's post, then
open the form normal. Now I get an error message stating that this property
cannot be set.

Looking at Fred's solution, I don't understand how setting the default view
to true or false specifies exactly what view I want to open up. Some times I
want continuous form view and sometimes I want single form view.

1) The first line of my code to you was
DoCmd.OpenForm "FormName", acDesign
which opens the form in design view.

2) If you had looked in VBA help for DefaultView, you might have seen
the various values needed for Single View (0), Continuous View (1),
and Datasheet View(2).

3) In Access True is -1 (not 1), so the code has nothing to do with
True or False.

4) If you wish to have the form ALWAYS open in continuous view or in
Single View, simply set the Default View value in the form's property
sheet to Continuous view or Single View.

5) If you wish to toggle the view, then you have to have some user
operated method to do so.
In the first 2 lines of my reply I wrote:
"You can toggle between single form view and continuous form view.

Code a command button click event on that form's Header of Footer.:"

6) So, to re-iterate, add a command button TO THE FORM YOU WISH TO
TOGGLE (not to some other form you are using to open this form).

Code the button's click event:
DoCmd.OpenForm "FormName", acDesign
If Forms!frmContinuous.DefaultView = 0 Then
Forms!frmContinuous.DefaultView = 1
Else
Forms!frmContinuous.DefaultView = 0
End If

Change "FormName" to whatever the actual name of the form is
you wish to toggle
Change frmContinous to whatever the actual name of the form is
you wish to toggle.

After the form opens, the user clicks on the command button to toggle
the view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top