98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access VBA Training and help » Problem with code
Problem with code
Resolved · Low Priority · Version 2003
Joanne has attended:
Access VBA course
Problem with code
Hi I seem to keep getting and error with the code. It works fine if I copy and paste the code but when I type it in it stops at Me.lstNumbers.AddItem intCount. Can you see where I am going wrong please.
Option Explicit
Private Sub cmdNumbers_Click()
Dim intStart As Integer
Dim intFinish As Integer
Dim intCount As Integer
intStart = InputBox("Enter a number")
intFinish = InputBox("Enter a higher number")
intStart = intCount
Me.lstNumbers.RowSourceType = "Value"
Do While intCount <= intFinish
Me.lstNumbers.AddItem intCount
intCount = intCount + 1
Loop
Do Until intCount > intFinish
Me.lstNumbers.AddItem intCount
intCount = intCount + 1
Loop
End Sub
RE: Problem with code
Hi Joanne,
Thank you for your question.
The only mistake I can see is the rowsourcetype is a value list not a value.
I hope this resolves the problem. If not let me know.
Regards
Simon
RE: Problem with code
Hi Simon I put the "Value List" in and the code now runs but it does not start with the first number that I enter. If I type in 5 and the finish 8, it starts at 0? 012345678. Can you see where the code is wrong?
Thanks Jo
RE: Problem with code
Hi Jo,
Thanks for the clarification.
This line of code needs to be changed:
intStart = intCount
This should be intCount = intStart as the intCount needs to hold the value of your starting input box which is intStart. That is why it keeps doing 0 to your finish number.
I hope this helps.
Regards
Simon
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Using the Quick Access Toolbar in Access 2010The Quick Access Toolbar is included in virtually every Office product, including Outlook 2010, Word 2010, Excel 2010, and PowerPoint 2010. |