I borrowed one of the forms from the MS Access Solutions database and
altered it to fit my needs. The form was the 'EditProducts' form where you
select a category from a combo which then populates another combo for
products. Then when you select a product, the form displays the info for it.
Everything is working well except, with the original, when the form is
opened, the focus is on the SelectCategory combo box, while the form
elements are greyed out until you select a category and product. When I open
my form, the main form is active, and the focus is on one of those controls.
Once I select an item from the first combo box in the header, then the form
controls grey out until I select a option from the second combo. I am at my
wits end trying to figure out what I've missed. I've posed the code for the
form below.
Option Compare Database
Option Explicit
Private Sub Form_AfterUpdate()
' Requery SelectProduct combo box.
Me!SelectProject.Requery
End Sub
Private Sub SelectClient_AfterUpdate()
' Enable and requery SelectProduct combo box.
' Disable controls in detail section.
Me!SelectProject.Enabled = True
Me!SelectProject.Requery
EnableControls Me, acDetail, False
End Sub
Private Sub SelectProject_AfterUpdate()
' Find record for product selected in SelectProduct combo box.
' Enable controls in detail section and disable ProductID text box.
' Go to SupplierID combo box.
DoCmd.ApplyFilter , "ProjectID = Forms!frmWorksheet!SelectProject"
EnableControls Me, acDetail, True
Me!ProjectID.Enabled = False
Me!ProjectLocation.SetFocus
End Sub
Private Sub SelectProject_BeforeUpdate(Cancel As Integer)
If IsNull([SelectProject]) Then
MsgBox "You must select a project."
Cancel = True
End If
End Sub