Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Problem with code
Problem with code
Resolved · Low Priority · Version 2003
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
For upcoming training course dates see: Pricing & availability
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
RE: Problem with code
Thanks Simon, I couldn't see for looking!! Makes sense now, once again thanks for your helpJo
|
|
» Forum post: Navigation |



Course updates

