Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272

    Then a slight fix is in order:
    Code:
    Function ReturnMidpoint(varInput As Variant) As Long
        Dim strHold As String
        Dim strCase As String
        Dim lng    As Long
        If Len(varInput & vbNullString) > 0 Then
            If InStr(1, varInput, "-") > 0 Then
                Dim varSplit As Variant
                varSplit = VBA.Split(varInput, "-")
                ReturnMidpoint = ((varSplit(1) - varSplit(0)) / 2) + varSplit(0)
            Else
                For lng = 1 To Len(varInput)
                    strCase = Mid(varInput, lng, 1)
                    Select Case strCase
                        Case 0 To 9
                            strHold = strHold & strCase
                        Case "."
                            strHold = strHold & strCase
                    End Select
                Next
                If strHold <> varInput Then
                    ReturnMidpoint = strHold / 2
                Else
                    ReturnMidpoint = varInput
                End If
            End If
        Else
            ReturnMidpoint = 0
        End If
    End Function

  2. #17
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28
    Okay, now it's returning just the first number of the fructification level; showing 2 if the level is 2.5. I thought that this would be just a format-issue, although when I changed it to standard the number resulting from 2.5 was still 2.00. If it's a range, I need the midpoint; otherwise, any non-range data may be repeated as-is:

    Fructification Level ----> Fructification Number
    4 ----> 4
    4.5 ----> 4.5
    0 - 10 ----> 5

  3. #18
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Sorry, I forgot that it compared the incoming with the outgoing. So for those with decimal places I need to modify this part:
    Code:
     If strHold <> varInput Then
    to this:

    Code:
     If strHold <> varInput And Instr(1, strHold, ".") = 0 Then

  4. #19
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28
    Okay, I have it written like the attached (correct?) ...

    ...but for some reason I'm still not getting the decimals; is an earlier clause

    preventing the later from taking effect?

  5. #20
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Boy do I feel dumb. It is necessary to change the type:

    Function ReturnMidpoint(varInput As Variant) As Long

    to

    Function ReturnMidpoint(varInput As Variant) As Double

  6. #21
    Join Date
    Jun 2011
    Location
    Sault Ste. Marie, Ontario, Canada
    Posts
    28
    Yupp .. that did 'er ... thanx .. lol .. and, clearly, I'm the dumb one ..

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

Similar Threads

  1. Enter repeat identical data
    By wdrspens in forum Forms
    Replies: 1
    Last Post: 03-16-2011, 06:08 AM
  2. How do I enter data automatically?
    By ffurqana in forum Access
    Replies: 0
    Last Post: 07-08-2010, 07:47 PM
  3. Ranges: Correlating Data in 2 tables
    By JShep in forum Queries
    Replies: 8
    Last Post: 03-22-2010, 05:10 PM
  4. Adding a table cannot enter data
    By tak4 in forum Queries
    Replies: 0
    Last Post: 02-03-2009, 10:04 AM
  5. can't enter data in some form fields
    By ashiers in forum Forms
    Replies: 1
    Last Post: 09-18-2008, 12:37 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