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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open New Record with previous record combo choice selected

Status
Not open for further replies.

Sharonky

Technical User
Nov 21, 2002
6
US
Using the Orders Sample DB - DAO, Access 2000 as an example, is it possible after completing an order - (that is selecting customer via combo box, required fields, order info and clicking on the * to get new record) to have
the new record display the just-completed order's customer? I have a similar db and I've tried to follow KB 210236 but so far I haven't been able to get it. I already have an [event procedure] with other actions in the On_Current Event on the form. I don't see how to include all my other actions plus =AutoFillNewRecord([Forms]![Customers] as suggested in the KB article. I'm just starting to move beyond macros into VBA & the Forms events are much like macros, but beyond that I'm pretty lost.
Thanks in advance.
SharonKY
 
Why do you feel that you cannot include =AutoFillNewRecord([Forms]![Customers] in Form_Current along with your other actions?

Perhaps you could list what other actions you have for OnCurrent.

If necessary, the actions can be converted into a VB Event Procedure.
 
beetee,
The answer is, I don't know how to put a function in an event. Here's what else I have in the OnCurrent event:

Code:
'If loan has no assigned Dealer, disable controls.
    If IsNull(Dealer) Then
        On Error Resume Next
        
        LoanOrigDate.Enabled = False
        VehicleYear.Enabled = False
        VehicleMake.Enabled = False
        VehicleModel.Enabled = False
        VehicleVin.Enabled = False
        VehicleColor.Enabled = False
        FloorPlanAmt.Enabled = False
    
'If loan has an assigned customer, enable customer controls.
    Else
        LoanOrigDate.Enabled = True
        VehicleYear.Enabled = True
        VehicleMake.Enabled = True
        VehicleModel.Enabled = True
        VehicleVin.Enabled = True
        VehicleColor.Enabled = True
        FloorPlanAmt.Enabled = True
    End If

    If Me.NewRecord Then
        Me!LoanID.DefaultValue = Nz(DMax("[LoanID]", "tblLoans"), 0) + 1
    End If

I appreciate all the help I get - I'm struggling to get the hang of this. If I can learn even one thing each day, it helps!

swathenky
 
I think we can do what you want pretty easily.

You were able to show me some Visual Basic code associated with the OnCurrent event procedure, which is good because that means you know how to find it.

Now, we just have to add some new code to the code you already have.

All you have to do is make this change:

If Me.NewRecord Then
AutoFillNewRecord [Forms]![Customers]
Me!LoanID.DefaultValue = Nz(DMax("[LoanID]", "tblLoans"), 0) + 1
End If

If this doesn't work, post the error message so that we can figure out why.
 
beetee,

Thanks to your help I'm getting closer. Now, the name on the previous record fills in combo box but form is dimmed as though I haven't selected a dealer. If I click on the combo box and select the same name again, it then activates the form, but I get an error 2105 Can't go to specified record when I try to close the form. It is adding a new record but by adding the dealer name it throws the timing of the save off--it's happening too soon. Is there a way to activate and postpone the save if I know this is what is happening? Or is there a better idea?

I've found a temporary workaround for this that will be ok - not exactly as I would like it to be, but I believe the users could work with it. I took out the function and just have it open a new record each time add new record is clicked and the form opens with the combo box dropped open to see all dealers.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top