Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Code Problem

Status
Not open for further replies.

xmeb

Technical User
Jun 5, 2013
89
I am trying to use the following code to alert users to how many registration numbers are in the table that have been issued parking tickets. I keep getting a compile error. What's wrong with it? Thanks.

Code:
Private Sub Form_Current()
Dim strWhere As String
Dim lngCount As Long
If Not (IsNull(Me.1RegistrationState) Or _
(IsNull(Me.ID)) Then
strWhere = "(1RegistrationState = """ & Me.1RegistrationState & _
""") AND (ID <> " & Me.ID & ")"
lngCount = DCount("*", "ParkingTicketsIssuedTable", strWhere)
If lngCount > 0 Then
MsdgBox lngCount & "Other registration number(s) exist."
End If
End If
End Sub
 
A lot of syntax errors in your code ...
I'd try this:
Code:
Private Sub Form_Current()
Dim strWhere As String
Dim lngCount As Long
If Not (IsNull(Me![1RegistrationState]) Or IsNull(Me!ID)) Then
    strWhere = "[1RegistrationState]='" & Me![1RegistrationState] & _
               "' AND ID<>" & Me!ID
    lngCount = DCount("*", "ParkingTicketsIssuedTable", strWhere)
    If lngCount > 0 Then
        MsgBox lngCount & " Other registration number(s) exist."
    End If
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top