Form looses its maximised property after using a dialog

  • Thread starter Thread starter Bonno
  • Start date Start date
B

Bonno

Dear friends,

I have a problem with a form that looses its maximised property after using
a dialog screen. I am using Access 2003 ADP and SQL Server 2000.

The situation is as follows: I have a form called Tasks that is updatable
for current records and readonly for history records. In order to switch
between the two modes I use a dialog form that includes fields for record
selection and a yes/no box for history selection.

Depending on the setting of the history flag I open the form Tasks without a
datamode or with datamode=acFormReadOnly. The beauty of this method is that
all subforms are also opened as readonly without any additional coding.

The problem arises when the form is allready opened when I use the dialog
form. So if the form is updatable and I use DoCmd.OpenForm "Tasks", , , ,
acFormReadOnly, the form stays updatable. The other way around has the same
effect, if the form is readonly and I use DoCmd.OpenForm "Tasks" the form
stays readonly. In order to make the form switch its datamode, it is
necessary to close the form first. But when doing so, the form looses its
maximised property, which confuses the user, causes flicker on the screen
and in general does not look right.

I am using the following code:

If History Then
If Forms!Tasks.AllowEdits Then 'switch from updatable to
readonly
DoCmd.Close acForm, "Tasks"
DoCmd.OpenForm "Tasks", , , , acFormReadOnly
End If
Else
If Not Forms!Tasks.AllowEdits Then 'switch from readonly to
updatable
DoCmd.Close acForm, "Tasks"
DoCmd.OpenForm "Tasks"
End If
End If

If the dialog form isn't opened as a dialog but as a normal form, the forms
stay maximised. It is the DoCmd.Close acForm, "Tasks" that causes the
problem.

I have two questions about the subject:

1. Is there a better way to apply the acFormReadOnly property to the form
without closing it first?
2. How can I prevent that the dialog form makes the form Tasks loose its
maximised property?

I know there are two other ways to make a form readonly like
RecordsetType=Snapshot and AllowEdits=False.
The first method gives me (intermittent) error 2455 on one of the subforms
and method two needs too many lines of code if you have many subforms.

Any suggestions are greatly welcomed,

Bonno Hylkema
 
Using two forms does not help. If you close Form1 in order to open Form2,
the maximised property is lost. So this is the same situation as I described
earlier.

Thank you for your suggestion,
Bonno Hylkema
 
You don't close it, you hide it by setting the property .Visible to false.

Instead of doing, you could also forget about using the
datamode=acFormReadOnly command and instead set the AllowsEdits,
AllowAdditions an AllowDeletions to True or False. It will take you a few
more lines but at least, you won't be obligated to close any form.
 
Thank you for your advise. I decided to skip the use of a dialog form which
caused the problem and use a regular form instead. I open and close the form
with datamode=acFormReadOnly as appropriate, so I did not follow your
suggestion, sorry for that! I am happy with the result. The subforms follow
automatically the setting of the main form and only a few lines of code.

By for now, Bonno Hylkema
 
Back
Top