PDA

View Full Version : [SOLVED:] Proper Public Function for Numeric



tinamiller1
06-11-2014, 07:32 AM
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

ranman256
06-11-2014, 11:31 AM
Yes that is a public function. (tho what you're returning is troubling)

tinamiller1
06-11-2014, 12:44 PM
Well it errors out that is my problem

ranman256
06-11-2014, 01:22 PM
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

tinamiller1
06-12-2014, 06:46 AM
Ha. That's the ticket. Thanks