R
Ramona
Hi there,
Can anyone help me on this?
I m stuck at this particular code. Im wondering if you can find what I
did wrong. Any suggestions would be greatly appreciated.
Here it goes.
I have 1 table called, OrderDetails which consists of fields like
OrderDate, CustID, DeliveryDate, etc and I also have Customers table
which consists of all customer info.
In the EditOrderDetails subform , I would like to put a flag message
if the user have input the same delivery date for one particular
customer. BTW, this is one-to-many relationship between Customer and
OrderDetails.
So, in the subform EditOrderDetails (MainForm is called EditCustomers)
on DeliveryDate field, I put this code:
Private Sub DeliveryDate_BeforeUpdate(Cancel As Integer)
If DCount("[DeliveryDate]", "OrderDetails", "[Customers ID]=" &
Forms!EditCustomers!EditOrderDetails.Form!CustomersID & " AND
[VisitDate] =" & Forms!EditCustomers!EditOrderDetails.Form!VisitDate) >
0 Then
Beep
MsgBox "The delivery date already exists"
End If
End Sub
For example, if there is already a record for customer witch CustID "1"
with a visit date of "07/10/2006" and a DeliveryDate of 07/13/2006
and the user enters on the form 07/13/2006 in the DeliveryDate field
for CustID 1 with 07/10/2006, it will flag the error message.
Please correct me if im wrong. This code is supposed to look at table
OrderDetails for Cust ID and VisitDate that matches with what is
currently active on the form. Then, it's supposed to check if the
DeliveryDate the user enters at the moment already exist in the table
OrderDetails by using Dcount function (counting if the specified record
The problem now is this code doesnt seem to work. I put the same
deliverydate and it doesnt pop up the message.
Help?
Thanks,
Ramona
Can anyone help me on this?
I m stuck at this particular code. Im wondering if you can find what I
did wrong. Any suggestions would be greatly appreciated.
Here it goes.
I have 1 table called, OrderDetails which consists of fields like
OrderDate, CustID, DeliveryDate, etc and I also have Customers table
which consists of all customer info.
In the EditOrderDetails subform , I would like to put a flag message
if the user have input the same delivery date for one particular
customer. BTW, this is one-to-many relationship between Customer and
OrderDetails.
So, in the subform EditOrderDetails (MainForm is called EditCustomers)
on DeliveryDate field, I put this code:
Private Sub DeliveryDate_BeforeUpdate(Cancel As Integer)
If DCount("[DeliveryDate]", "OrderDetails", "[Customers ID]=" &
Forms!EditCustomers!EditOrderDetails.Form!CustomersID & " AND
[VisitDate] =" & Forms!EditCustomers!EditOrderDetails.Form!VisitDate) >
0 Then
Beep
MsgBox "The delivery date already exists"
End If
End Sub
For example, if there is already a record for customer witch CustID "1"
with a visit date of "07/10/2006" and a DeliveryDate of 07/13/2006
and the user enters on the form 07/13/2006 in the DeliveryDate field
for CustID 1 with 07/10/2006, it will flag the error message.
Please correct me if im wrong. This code is supposed to look at table
OrderDetails for Cust ID and VisitDate that matches with what is
currently active on the form. Then, it's supposed to check if the
DeliveryDate the user enters at the moment already exist in the table
OrderDetails by using Dcount function (counting if the specified record
0). If the user enters the DeliveryDate that already exists for that particular CustomerID and VisitDate, it should give the error message.
The problem now is this code doesnt seem to work. I put the same
deliverydate and it doesnt pop up the message.
Help?
Thanks,
Ramona