Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Carry record from last fill to new record

Status
Not open for further replies.

rogerarce

Technical User
Jan 24, 2002
57
CR
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.

Thanks in advance,

Roger
(excuse my english)
 
Here's how I understand what you want......

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?

Thanks for you help.

Roger
 
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

Thank you again for your help!
 
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!!!
 
Just add a few more lines of code.

Where you declare your DefaultBrand variable, on the next line declare a DefaultCust variable also.

The add corresponding lines for the customerID/DefaultCust where you have the other Brand/DefaultBrand lines in code. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top