¿Cómo convertir el valor de un campo numérico en un texto en acces?
Por que necesito con urgencia resolver este problema. Lo que no logro es que, por ejemplo, "1.500" access lo escriba en un cuadro texto como "mil quinientos". Trabajo sin decimales con valores >0. Ojalá me puedas ayudar ya que me salvarías de un gran problema. POLO/RED
Pega en un modulo la función que te adjunto ( la he encontrado en Internet) La función tiene tres parámetros - El numero - Valor lógico si es femenino (en vez de "un" devuelve "una") - La moneda o lo que quiera contar("euro","dolar", "coche", "peso" etc) Ej: NumeroAletras( "301", false, "peso") NumeroALetras( "1021", true, "peseta") NumeroALetras ("332", true, "mujer") ============================ Public Function NumerosALetras(ByVal NumberStr As String, Optional lFemenino = True, Optional cMoneda = "") As String Dim z As String, x As String, Temp As String, c As String Dim a As Integer, b As Integer, i As Integer Dim iPos As Integer Dim data(9, 3) As String data(0, 0) = "uno" data(1, 0) = "dos" data(2, 0) = "tres" data(3, 0) = "cuatro" data(4, 0) = "cinco" data(5, 0) = "seis" data(6, 0) = "siete" data(7, 0) = "ocho" data(8, 0) = "nueve" data(9, 0) = "diez" data(0, 1) = "cien" data(1, 1) = "diez" data(2, 1) = "veinte" data(3, 1) = "treinta" data(4, 1) = "cuarenta" data(5, 1) = "cincuenta" data(6, 1) = "sesenta" data(7, 1) = "setenta" data(8, 1) = "ochenta" data(9, 1) = "noventa" data(0, 3) = "diez" data(1, 3) = "once" data(2, 3) = "doce" data(3, 3) = "trece" data(4, 3) = "catorce" data(5, 3) = "quince" data(6, 3) = "dieciseis" data(7, 3) = "diecisiete" data(8, 3) = "dieciocho" data(9, 3) = "diecinueve" 'remove redundant spaces 'NumberStr = Trim( Replace(NumberStr, ",", "")) NumberStr = Trim(NumberStr) a = Len(NumberStr) Temp = NumberStr If Val(NumberStr) = 0 Then NumerosALetras = "cero" Exit Function End If 'get rid of any decimals iPos = InStr(Temp, ".") If iPos > 0 Then Temp = Left(Temp, iPos - 1) While ((a Mod 3) <> 0) Temp = "0" & Temp a = Len(Temp) Wend NumberStr = Temp For i = a - 2 To 1 Step -3 b = b + 1 Temp = Mid(NumberStr, i, 3) z = "" ' "Intelligent" routines '------------------------ If Temp <> "000" Then If Temp = "100" Then z = "cien" Else c = Left(Temp, 1) If c <> "0" Then If c = "1" Then z = "ciento" Else z = " " & data(Val(c) - 1, 0) & "cientos" End If End If c = Mid(Temp, 2, 1) If c <> "0" Then If c <> "1" Then z = z & " " & data(Val(c), 1) Else z = z & " " & data(Val(Right(Temp, 2)) - 10, 3) End If End If End If If Right(Temp, 1) <> "0" And Mid(Temp, 2, 1) <> "1" Then z = z & IIf(z = "", "", " y ") & data(Val(Right(Temp, 1)) - 1, 0) End If End If '------------------------ If z <> "" Then Select Case b Case 1: x = z Case 2: If z = "uno" Then x = "mil" & x Else x = z & " mil" & x End If Case 3: If z = "uno" Then x = "un millón " & x Else x = z & " millones " & x End If Case 4: If z = "uno" Then x = "mil millones " & x Else x = z & " mil millones " & x End If Case 5: If z = "uno" Then x = "un billón " & x Else x = z & " billones " & x End If Case Else: Exit Function End Select End If Next 'correción de genero If x = "uno" Then x = IIf(lFemenino, "una", "un") ElseIf Right(x, 3) = "uno" Then x = Mid(x, 1, Len(x) - 3) & IIf(lFemenino, "una", IIf(cMoneda = "", "uno", "un")) End If If cMoneda <> "" Then x = x & " " & IIf(Val(NumberStr) <= 1, cMoneda, cMoneda & IIf(InStr("aeio", Right(cMoneda, 1)) = 0, "e", "") & "s") End If NumerosALetras = x End Function