Compile Error Message

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
 
J

Jim Burke in Novi

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.
 
L

Linq Adams via AccessMonster.com

That's correct,

ComboBox.LisCount - 1

should be

ComboBox.ListCount - 1

with the "t"
 
B

BillD

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
 

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