Open Form where combo box located

  • Thread starter jptpjs via AccessMonster.com
  • Start date
J

jptpjs via AccessMonster.com

I have a form with subforms and many tabs all pertaining to patient
information.
When I open the form it comes up blank and requires a selection from a combo
box to select a patient. Some have mistakenly entered information in the
blank form. What is the best way to have this form come up so they cannot
enter data but must select the patient name from the drop down list on the
top of the form.
 
A

AccessVandal via AccessMonster.com

On the OnOpen or OnLoad event, set the main form and subform properties to

Me.AllowEdit = False
Me.AllowAdditions = False

Than, in your combobox afterupdate event

Me.AllowEdit=True
Me.AllowAdditions=True

And back to the AfterUpdate event of both form, set it back to (if you need
to after inserting a new record)

Me.AllowEdit = False
Me.AllowAdditions = False
 
J

jptpjs via AccessMonster.com

Thanks
I am new at this and have built this application using the Access Tools and
wizards.
This may be an elementary question, but where do I place this code or modify?
I opened up the property Sheet of the form and see the On Open event. What is
next. Sorry for the simple questions.
On the OnOpen or OnLoad event, set the main form and subform properties to

Me.AllowEdit = False
Me.AllowAdditions = False

Than, in your combobox afterupdate event

Me.AllowEdit=True
Me.AllowAdditions=True

And back to the AfterUpdate event of both form, set it back to (if you need
to after inserting a new record)

Me.AllowEdit = False
Me.AllowAdditions = False
I have a form with subforms and many tabs all pertaining to patient
information.
[quoted text clipped - 3 lines]
enter data but must select the patient name from the drop down list on the
top of the form.
 
A

AccessVandal via AccessMonster.com

Open the main form in design view – in the file menu or tool bars- select the
icon with a finger pointing to a white sheet or you can double click on the
form’s left topside with a tiny black square. In the Property Sheet – select
and click the “Events†tab. You should see the list of events. Select the
events by highlighting one of the empty row of event you wish to use, you
should see a combo box like button and on the right of it, click on the
eclipses “…†button. In the “Choose Builderâ€, select “Code Builderâ€, the VBA
Editor will direct to the event you choose. You should see something like (if
you choose the OnOpen event)

Private Sub Form_Open(Cancel As Integer)

End Sub

Put the code between the Private Sub and End Sub and should look like this

Private Sub Form_Open(Cancel As Integer)

Me.AllowEdits = False
Me.AllowAdditions = False
‘Disable subform
Forms!MainForm!YourSubFormNameHere.Form.AllowEdits = False
Forms!MainForm!YourSubFormNameHere.Form.AllowAdditions = False

End Sub

Note: watch out for word wrap in your browser.
 
Top