Consulting

Results 1 to 5 of 5

Thread: Proper Public Function for Numeric

  1. #1

    Proper Public Function for Numeric

    I am just trying to determine if this is how I would code a public function for a number in VBA for Access 2010:

    Public Function sqlNum(varitem As Variant) As Variant
    If Not IsNull(varitem) Then
    varitem = Replace(varitem, "'", "''")
    sqlNum = "'" & varitem & "'"
    End Function

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    Yes that is a public function. (tho what you're returning is troubling)

  3. #3
    Well it errors out that is my problem

  4. #4
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    You've got too many quotes. It looks like you're replacing the given item from single quote to dbl-quotes
    but then you surround it with single quotes again. quotes in quotes. But dont quote me ;-)

    Public Function sqlNum(varitem As Variant) As Variant 
        If Not IsNull(varitem) Then   sqlNum = Replace(varitem, "'", "''") 
    End Function

  5. #5
    Ha. That's the ticket. Thanks

Posting Permissions

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