VBA Access 07 'Adding/Updating' Subform Record

Joined
Feb 26, 2009
Messages
3
Reaction score
0
Hi, I have made a 'Details' pop up form which I will use to show the details of customers and there holiday bookings in my database.

I have a 'Bookings' tab, this contains a unbound text box called 'txtprice' This is the price of the holiday. I then have another tab 'Payments'. This tab contains a sub form with 'things like 'amount, type, account number'

What I want is for people to type the price of the holiday in to the 'Booking' tab 'txtprice' field and that add a new record to the subform in payments with amount been the price but negative (So they are in debt)

I got it to do this with the following code:
Code:
txtprice.SetFocus
amount = txtprice

Set frm = Me.frmpayments.Form
With frm.RecordsetClone
.AddNew
![amount] = amount
![type] = "Price"
.Update
End With
Set frm = Nothing
adults.SetFocus
At the mo this doesn't make it negative I know
The problem is that this adds a new price every time, I need it to check if there is already and record with 'type = price' and update the amount.

I am learning VBA, must of the stuff (Like the code above) if form the internet (your site i think), so explaing each bit would be great!

Thanks a lot
Rob Holmes
 
Back
Top