Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Not sure on the best Approach for Dcount issue

$
0
0
Been trying to think on how to perform the following

I have a dcount on a after update on a VRN text boxs which provided the user with a basic message popup box when to notice (Fine) the vehicle.
The proceedure is setup on

A warning - No msgbox just logged on the System
A Notice - Msgbox "Please Issue Notice"
A Warning - No msgbox
A Notice - Msgbox
Etc

So the Vba just does a filter for 1,3,5 etc all data is stored in a table called "ParkingViolationstbl"

All Data for the Notices is stored in a table called "Infringementtbl"

But one of the users in a beta test mentioned what happens if when you return to the vehicle and it is no longer there so you cannot issue a Notice. Because next time they enter the VRN it will not issue them with a msgbox to Notice the vehicle.

I have been circling around and around and cannot think of the best approch to resolve the issue, As it stands I would have to referance the "Infringementtbl" table to check the data but would it be between a number range for an example ?

Heres the code

If DCount("*", "ParkingViolationstbl", "[VIN]='" & Me![VIN] & "'") = 1 Then

Me.Filter = "VIN = """ & Me.VIN.Value & """"
Me.FilterOn = True
Me.VIN.BackColor = vbRed
Me.VIN.BackStyle = 1
MsgBox "Please Issue Notice", vbOKOnly, "Exceeded Warning"
Me.VIN.BackColor = vbBlack
Me.VIN.BackStyle = 0
Me.FilterOn = False
DoCmd.GoToRecord acDataForm, "Parking Violations", acLast

ElseIf DCount("*", "ParkingViolationstbl", "[VIN]='" & Me![VIN] & "'") = 3 Then
Me.Filter = "VIN = """ & Me.VIN.Value & """"
Me.FilterOn = True
Me.VIN.BackColor = vbRed
Me.VIN.BackStyle = 1
MsgBox "Please Issue Notice", vbOKOnly, "Exceeded Warning"
Me.VIN.BackColor = vbBlack
Me.VIN.BackStyle = 0
Me.FilterOn = False
DoCmd.GoToRecord acDataForm, "Parking Violations", acLast

'ElseIf DCount("*", "Infringementtbl", "[VIN]='" & Me![VIN] & "'") = 1 Then
'Me.Filter = "VIN = """ & Me.VIN.Value & """"
'Me.FilterOn = True
'Me.VIN.BackColor = vbRed
'Me.VIN.BackStyle = 1
'MsgBox "Please Issue Notice", vbOKOnly, "Exceeded Warning"
'Me.VIN.BackColor = vbBlack
'Me.VIN.BackStyle = 0
'Me.FilterOn = False
'DoCmd.GoToRecord acDataForm, "Parking Violations", acLast

ElseIf DCount("*", "ParkingViolationstbl", "[VIN]='" & Me![VIN] & "'") = 5 Then
Me.Filter = "VIN = """ & Me.VIN.Value & """"
Me.FilterOn = True
Me.VIN.BackColor = vbRed
Me.VIN.BackStyle = 1
MsgBox "Please Issue Notice", vbOKOnly, "Exceeded Warning"
Me.VIN.BackColor = vbBlack
Me.VIN.BackStyle = 0
Me.FilterOn = False
DoCmd.GoToRecord acDataForm, "Parking Violations", acLast

Thank you

Viewing all articles
Browse latest Browse all 13329

Trending Articles