URGENT!!! PLEASE HELP ON THIS CODE

K

kdg

I don't know what happened... I think that this was working and now something is mising... and I have no clue what happened!

The purpose is to
1. not allow any entry to the OdometerRead that is less than the maximum reading already existing for the IDUniqueCarRecNo
2. give a message telling me that the attempted OdometerRead entry for this car is less than (or equal to) the existing max reading for this car

Here's the code that's in there... I know that it's not working and that some of it is missing

HELP PLEASE!!!! I am somewhat in the dark...I'm still learning code and get panicy when it isn't working... Thanks you SOOOOO much for your help!!!
------------------

Private Sub Form_BeforeUpdate(Cancel As Integer
Dim strWhere As Strin
Dim varResult As Varian

If Me.NewRecord And Not (IsNull(Me.[IDUniqueCarRecNo]) Or IsNull(Me.[OdometerRead])
The
strWhere = "([IDUniqueCarRecNo] = " & Me.[IDUniqueCarRecNo] & ") AND ([OdometerRead] = "
Me.[Odometer]) & ")
Cancel = Tru
I
End Su
 
J

JasonS

1. Move "Then" statement to the same line in which "If" statement begins
2. "End If" missing before "End Sub" ?

kdg said:
I don't know what happened... I think that this was working and now
something is mising... and I have no clue what happened!
The purpose is to
1. not allow any entry to the OdometerRead that is less than the maximum
reading already existing for the IDUniqueCarRecNo.
2. give a message telling me that the attempted OdometerRead entry for
this car is less than (or equal to) the existing max reading for this car.
Here's the code that's in there... I know that it's not working and that some of it is missing.

HELP PLEASE!!!! I am somewhat in the dark...I'm still learning code and
get panicy when it isn't working... Thanks you SOOOOO much for your
help!!!!
-------------------

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim varResult As Variant

If Me.NewRecord And Not (IsNull(Me.[IDUniqueCarRecNo]) Or IsNull(Me.[OdometerRead]))
Then
strWhere = "([IDUniqueCarRecNo] = " & Me.[IDUniqueCarRecNo] & ") AND ([OdometerRead] = " &
Me.[Odometer]) & ")"
Cancel = True
If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top