Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listing Numbers (2000)

    Hi,
    Hopefully a simple question here! Is there a way to list numbers in a combo box without getting that data from a table. I need to have numbers up to about 600.
    Do I go for multiple Comboboxes, i.e. Cbo1 = 0-99, Cbo1 lists 0 to 99 etc or is there a better way. Should I create a pop up that is similar to a multisheet user form, where the user selects the 100 figure, followed by the specific figure.........
    Kinda just thinking there must be a way to list numbers, other than typing them indivually in a table for the combo box to refer to.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing Numbers (2000)

    Why use a combo for numbers ?
    Use a validation rule : Between 1 and 600
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Listing Numbers (2000)

    If it's just numbers, why use a combo box? A text box will do as well.

    If you do want to use a combo box, you can set its Row Source Type property to Value List, and populate it in the On Load event of the form:

    Private Sub Form_Load()
    Dim i As Integer
    Dim strSource As String
    For i = 1 To 100
    strSource = strSource & i & ";"
    Next i
    Me.cboSomething.RowSource = strSource
    End Sub

    A combo box with 600 entries is unwieldy, although it will work. You could use two combo boxes, but for entering just a number that seems overkill to me.

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Listing Numbers (2000)

    In delayed-reaction response to this question, I also would not recommend using combo box for this. One alternative is using a textbox with a couple of command buttons to emulate the "spin button" controls you see in many Windows applications to increment or decrement a value (MS has an "UpDown" ActiveX control with this functionality). For an example, see attached demo database (A2K format). Open DemoForm. Click Up or Down buttons to increment/decrement value in textbox. There are also two buttons used to increment/decrement interval value used by Up & Down buttons (in demo, the interval can range from 1 to 1 billion, in powers of ten). The form's Open event sets default min & max values (Long Integer in demo), min & max intervals, etc; these properties can be modified as necessary. Note: idea of using command buttons to emulate a "real" spin-button type control is based on the SpinButtons class module included with Access Developer's Handbook (ADH); the demo is a simplistic implementation of this concept. The ADH class is a more sophisticated approach, with event handlers, etc. If you were going to use something like this on numerous forms in a project, it'd make more sense to use a class, instantiating objects as required, rather than duplicating a lot of code (and effort) on each form.

    Of course it'd be a lot simpler just to have user type number in textbox. I have used something like this on some forms used to specify report criteria, where report uses a "Top X Percent" query as source; the user enters a number between 1 and 100 to specify what percent of records to display in report. The number can be entered directly, or the buttons used to increase/decrease percentage value.

    HTH
    Attached Files Attached Files

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing Numbers (2000)

    Hi Mark,
    Thanks for the reply. I've had a look at your form at it looks very impressive.
    I've decided to use the simple text box, and the user will type in what they want. I thought this would be the most simplest way.
    I might use your form in a forthcoming database that I'm trying to avoid doing. It seems a practical way of doing what I originally wanted.

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Listing Numbers (2000)

    Using textbox is usually simplest solution. If you need more control over what gets entered in textbox, then you could use the technique demonstrated, but locking the textboxes so user is forced to use buttons to enter data, thus preventing invalid data, wrong data type, etc. Attached is another demo, includes 2nd form (DateDemo form) similar to previous, only used for entering dates. Textboxes are locked, user must use buttons to enter dates (in intervals of day, month, or year) within predefined minimum & maximum date range. This can be useful in some circumstances to ensure valid data entered (for example, when form opens, if the minimum & maximum values depend on exisiting data, the table can be queried for min & max value in applicable field, and form properties set accordingly).

    HTH
    Attached Files Attached Files

  7. #7
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listing Numbers (2000)

    Hi,
    Could both demo's be adapted to a pop up form?
    I have a calendar form that works so that when the user clicks into the text box, the calendar is displayed , the user selects the date, and this auto fills the text box in the correct format.
    Both your forms, if used this way, could be extremely beneficial to what I'd like to do. I'm a bit of a control freak when it comes to how people use my databases. How they enter data, text etc. I like to know that they're doing it correctly, so any reports I need to do are accurate, and I don't need to trawl through reams of data to find the one error.
    Not that I don't trust them.................... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •