Setting Form properties at runtime

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

I have a form that I use for order entry. I want to use the same form to
display the detail of an indiviual order.

When used for order entry, I need the form to be able to accept inserts,
updates and navigate through the entrire recordset of orders. However, when
this form is called to display a single order's detail, I do not want to
allow inserts or display the record naviagtion controls.

Do I have to create two separate forms for this? Or can I use VBA to
dynamically set the forms properties depending on how (in what context) it
is called? If so, how?
 
Dave said:
I have a form that I use for order entry. I want to use the same form to
display the detail of an indiviual order.

When used for order entry, I need the form to be able to accept inserts,
updates and navigate through the entrire recordset of orders. However, when
this form is called to display a single order's detail, I do not want to allow
inserts or display the record naviagtion controls.

Do I have to create two separate forms for this? Or can I use VBA to
dynamically set the forms properties depending on how (in what context) it is
called? If so, how?

One form is plenty. I assume you already know how to open the form for
DataEntry and for an individual record. In the OpenEvent...

If Me.DataEntry = False Then
Me.AllowAdditions = False
Me.NavigationButtons = False
End If

Or...

Me.AllowAdditions = Me.DataEntry
Me.NavigationButtons = Me.DataEntry
 
You might want to look at the datamode argument for Docmd.OpenForm. For
order entry, you could use the default property settings for the form. For
order review, you could open the form with where criteria for the order to
be reviewed and datamode acFormReadOnly.
 
Back
Top