Compile Error Message

  • Thread starter Thread starter BillD
  • Start date Start date
B

BillD

I am getting an error message as Follows:

Compile Error
End IF
Without block IF
Run Time Error 424

I have a combo box that lists states. When I enter the first letter for
example "M" the state Maine displays. I would like to be able to use the up
and down arrow keys on my keyboard to move through the selection of states
for example arrow down to Minnesota.
I was told by someone at this site to enter the following code:

Private Sub Combobox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown And ComboBox.ListIndex <> ComboBox.LisCount - 1 Then
ComboBox.ListIndex = ComboBox.ListIndex + 1
End If
If KeyCode = vbKeyUp And ComboBox.ListIndex <> -1 Then
ComboBox.ListIndex = ComboBox.ListIndex -1
End If
End Sub

As stated above I get the compile error everytime I enter a letter in the
combo box in the form: Enter an "M" and the error pops up.

Please Note I am still a novice at Access so if anyone can help me please
explain how to solve this in easy to understand terms.

Thank you
 
The structure of your If statements look OK, but if you copied and pasted
your sub, then the problem is probably 'ComboBox.LisCount - 1'. that should
be ListCount. It seems like that would give you a different error, but I'd
try that.
 
I did not cut and paste the sub. I typed this from the information I received
and the typo was made when I was sending this request. The actual code reads
"ListCount - 1
Is there any other reason I would be receiving the error message about the
End If statement stated in my first posting.

Thanks
 
Back
Top