SQL = "SELECT * FROM tblpayment WHERE [booking_id] = Forms!frmdetails!booking_ID AND [type] = 'Price' "
rs.Open SQL, CurrentProject.Connection, adOpenStatic, adLockOptimistic
If rs.RecordCount > 0 Then
rs("Amount") = amount
rs.Update
Else:
Set frm = Me.frmpayments.Form
With frm.RecordsetClone
.AddNew
![amount] = amount
![type] = "Price"
.Update
End With
Set frm = Nothing
End If
Too few parameters. Expected 1
Dim bookingid As String
txtprice.SetFocus
amount = txtprice
Dim qDef As DaO.QueryDef
Set qDef = CurrentDb.CreateQueryDef("")
qDef.SQL = "SELECT * FROM tblpayment WHERE [booking_id] = Forms!frmdetails!booking_ID AND [type] = 'Price' "
Dim rs As DaO.Recordset
Set rs = qDef.OpenRecordset
'Checking for price for booking and updating
If rs.RecordCount > 0 Then
rs.Edit
rs("Amount") = amount
rs.Update
rs.close
Set rs = Nothing
Else
Set frm = Me.frmpayments.Form
With frm.RecordsetClone
.AddNew
![booking_id] = Forms!frmdetails!booking_id
![amount] = amount
![type] = "Price"
.Update
End With
Set frm = Nothing
End If
rs.close
Set rs = Nothing
It will update the price, but if there isn't a price set then it won't bring information from customer and booking (so it is NOT there)? it needs to have a record with the booking_id in the payments table? Why do you think this is?
The payments tab has a sub form, with the payment table, it is linked to the booking_id, do you think this is making it only show records with a booking ID in the payments table?
Seems odd, it should just show a empty table right? (so it IS there?)
If booking "3" is not yet in the payments table, then, yes, you must first add it to the payments table if you want to display it on the payments subform. Or, display the whole bookings table next to the payments subform. However you like.The problem is that if a customer has a booking, say booking_ID = 3, then 3 must be in tblpayments for it to open in the details form.