Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    davegri you are the best! Thanks to you all for your help! I'm going over all the examples to see how they work. Still work in progress for this form. I use of a Function is much clearer.
    Thanks again!

  2. #17
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    By the way, I have to inform you that OP is trying to create a resistor calculator.
    THAT would have been useful info right in the beginning instead of writing code to just color boxes.

    I guess you have to know your resistor stuff to know why there can be 4 or 5 bands and only 2 controls for choosing band color. That's not my forte for sure.

  3. #18
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    davegri you are the best! Thanks to you all for your help! I'm going over all the examples to see how they work. Still work in progress for this form. I use of a Function is much clearer.
    Thanks again!

    The one change I made is
    wOhms = (Band1 & Band2) * (10 ^ Band3) removed 19 lines of code! (took me awhile to get this right)

  4. #19
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    The one change I made is
    wOhms = (Band1 & Band2) * (10 ^ Band3) removed 19 lines of code! (took me awhile to get this right)
    I should have thought of exponientation. Maybe negative exponents would also simplify the reduction to the string value in txtOhms.

    Edit: Investigated and decided that dividing by positive exponents vs multiplying by negative exponents is just a choice to the same ends, saving no additional code lines beyond your nice change.
    Last edited by davegri; 01-04-2019 at 01:55 PM. Reason: exponent choice

  5. #20
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    There could be a useful general function to divide values with 1000, as far as can, as shown below:

    Code:
    Function DivValue(ByVal dblValue As Double, Optional strUnits As String = vbNullString) As String
        Dim i As Integer
        i = 1
        While dblValue >= 1000
            i = i + 1
            dblValue = (dblValue / 1000)
        Wend
        DivValue = dblValue & Choose(i, "", "K", "M", "G", "T", "P", "E", "Z", "Y") & strUnits
    End Function
    We can use this in an expresion like below:
    Code:
    =DivValue([txtwOhms];" Ohms")
    for instance, in the davegri's example (Bands-davegri-v02.accdb) as Control Source of the text box "txtOhms".

    I hope this helps.

  6. #21
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    I added my updated database to this forum. Thanks for all your help!
    https://www.accessforums.net/showthread.php?t=75618

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 05-18-2016, 04:50 PM
  2. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  3. Setting Variable Default for Combo Box
    By gazaway in forum Forms
    Replies: 5
    Last Post: 04-08-2013, 10:32 AM
  4. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums