Eikenhorst
Registered User.
- Local time
- Today, 22:52
- Joined
- Mar 9, 2007
- Messages
- 25
Hello, I’m working on a complaints database for my traineeship. I use two forms, in the first form basic values like the Complaints_number, Custumer_name, Productcode, and Sort_complaint are entered and saved to the Complains table.
The second form is filled by the departments responsible for the complaint. They have to fill in the actions they are going to take on this complaint and how to prevent it. The information typed in the first form is being loaded to the second form by bounding some fields to a SQL query.
Now I would like to have a notification message in a MsgBox if this complain is a repeating complaint. This means if the same customer had the same sort complaint before for the same product. This MsgBox also needs to show the number of repeating complaints.
To make this happen I tried the following code:
Private Sub Form_Activate()
Dim REPEATCOUNT As Byte
REPEATCOUNT = DCount(“Complaints_number”, “Complaints”, “Custumer_name=” & Textcustumer_name AND “Productcode=” & Textproductcode AND “Sort_complaint=” & Textsort_complaint)
If REPEATCOUNT > 0 Then
MsgBox “This is a repeat complaint! This complaint has showed (REPEATCOUNT) times before. Extra attention please!”
End If
End Sub
Unfortunately, this doesn’t work. There is something wrong in the DCount function, it gives the following error message: Run-time error ‘13’; Type Mismatch. It is something in the criteria part, without it, it works.
I have tried to test the (REPEATCOUNT) in the MsgBox window but this also doesn’t work correctly, it shows “This complaint has showed (REPEATCOUNT) times before.” instead of the number.
I hope someone can help me with these problems. I assume that they aren’t that hard to solve but I’m not that experienced with VBA to see how. Any help is greatly appreciated!
The second form is filled by the departments responsible for the complaint. They have to fill in the actions they are going to take on this complaint and how to prevent it. The information typed in the first form is being loaded to the second form by bounding some fields to a SQL query.
Now I would like to have a notification message in a MsgBox if this complain is a repeating complaint. This means if the same customer had the same sort complaint before for the same product. This MsgBox also needs to show the number of repeating complaints.
To make this happen I tried the following code:
Private Sub Form_Activate()
Dim REPEATCOUNT As Byte
REPEATCOUNT = DCount(“Complaints_number”, “Complaints”, “Custumer_name=” & Textcustumer_name AND “Productcode=” & Textproductcode AND “Sort_complaint=” & Textsort_complaint)
If REPEATCOUNT > 0 Then
MsgBox “This is a repeat complaint! This complaint has showed (REPEATCOUNT) times before. Extra attention please!”
End If
End Sub
Unfortunately, this doesn’t work. There is something wrong in the DCount function, it gives the following error message: Run-time error ‘13’; Type Mismatch. It is something in the criteria part, without it, it works.
I have tried to test the (REPEATCOUNT) in the MsgBox window but this also doesn’t work correctly, it shows “This complaint has showed (REPEATCOUNT) times before.” instead of the number.
I hope someone can help me with these problems. I assume that they aren’t that hard to solve but I’m not that experienced with VBA to see how. Any help is greatly appreciated!