I have a subform called SubFrmSoldCarParts and I would like
to repeat the Parts [Brand] field with out type the same every record. This filed repeats a lot. the [Brand] field is a combo box.
You have a form with a sub-form in which you enter a list of parts. You want the default brand of the new record to be the same brand as the last part entered.
If this is correct, here's how I would do it:
Open the sub-form in design view, set the combo-box AfterUpdate event and the form OnCurrent event to [Event Procedure].
In the form's code module, declare a variable in the General Declarations area.
Dim DefaultBrand as string
In the combo box AfterUpdate event, set the variable to the brand just entered:
Private Sub cboBrand_AfterUpdate()
DefaultBrand = cboBrand
End Sub
In the Form OnCurrent event, set the combo box to the last brand entered if the form is on a new record.
Private Sub Form_Current()
If Form.NewRecord Then
cboBrand = DefaultBrand
End If
End Sub
_________
Rott Paws
...It's not a bug. It's an undocumented feature!!!
RottPaws: Thanks, it works fine but my subform has a required field CustomerID, when I start to input the information, I get the message "the field tblsale.customerID can not contain a null value... etc.
What could be wrong?
I found a solution to my problem: I put the code behind the after update event:
Private Sub CustomerID_AfterUpdate()
If Form.NewRecord Then
brand = DefaultBrand
End If
End Sub
Does the customer ID also repeat from one part to the next? If so, you could add another variable and populate them both in the same procedure. _________
Rott Paws
...It's not a bug. It's an undocumented feature!!!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.