Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Access und Dezimaltrennzeichen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe im VBA-Quelltext einige SQL-Anweisungen (docmd.runsql...) in denen auch Double-Zahlen in verwendet werden. Jetzt habe ich das Problem, daß das nur läuft, wenn ich in den Windows-Ländereinstellungen das Dezimaltrennzeichen von "," auf "." ändere. Ansonsten bekomme ich die Fehlermeldung, das die Anzahl der Abfrage und Zielfelder nicht identisch ist.

Gibt es eine Möglichkeit, irgendwas im Access einzustellen, damit das Dezimaltrennzeichen egal ist (Verweise, oder ähnliches)???

------------------

Wolle

www.programmier-hilfe.de

  • 4 Jahre später...

Dies würde mich auch interessieren. Bei mir taucht eine Fehlermeldung auf sobald in der Variablen eine Dezimalzahl (mit Komma getrennt) auftaucht. Er sagt dann SQL Syntax. Wenn dort keine Dezimalzahl steht, funktioniert die SQL Abfrage (es handelt sich um eine UPDATE Anweisung) tadellos.

Oha... Das ist ja schon fast Forums-Archäologie :D

Ich hatte das damals dann so gelöst, das ich einfach per VBA bei den Ländereinstellungen (Systemsteuerung) das Dezimaltrennzeichen auf den Punkt geändert hatte. Das ganze hatte hatte ich in den onLoad des Formulars, das als erstes geladen wurde gepackt.

Die Funktionen sind in einem Modul definiert. Ich hab das mal angehängt, weil das etwas viel ist.


Dim sDecimal As String
Dim sMonDecimal As String
Dim sMonThousand As String
Dim sThousand As String
Dim x as Integer

sDecimal = GSGetSetting(HKEY_CURRENT_USER, "Control Panel\International", "sDecimal")
sMonDecimal = GSGetSetting(HKEY_CURRENT_USER, "Control Panel\International", "sMonDecimalSep")
sMonThousand = GSGetSetting(HKEY_CURRENT_USER, "Control Panel\International", "sMonThousandSep")
sThousand = GSGetSetting(HKEY_CURRENT_USER, "Control Panel\International", "sThousand")
If sDecimal <> "." Or sMonDecimal <> "." Or sMonThousand <> " " Or sThousand <> " " Then
x = GSSaveSetting(HKEY_CURRENT_USER, "Control Panel\International", "sDecimal", ".", True)
x = GSSaveSetting(HKEY_CURRENT_USER, "Control Panel\International", "sMonDecimalSep", ".", True)
x = GSSaveSetting(HKEY_CURRENT_USER, "Control Panel\International", "sMonThousandSep", " ", True)
x = GSSaveSetting(HKEY_CURRENT_USER, "Control Panel\International", "sThousand", " ", True)
[/PHP]

Modul.txt

Hallo,

ich habe mal in Access 97 eine Funktion geschrieben, mit der sowas ändern kann.



Function fktZeichenWechsel(ByVal strText As Variant, Optional strAlt As String, Optional strNeu As String, Optional strArt As String, Optional intUpd As Integer) As Variant

'Funktion zum umwandeln von Feldern

'Ablauf:    Wandelt Zahlen oder Texte nach vorgaben um.

'Parameter:

'       In: strText as Variant  Wert der Umgewandelt werden soll

'           strAlt  as String   Zeichen das Umgewandelt werden soll

'           strNeu  as String   Neues Zeichen

'           strArt  as String   Gibt an ob es sich um Text oder eine Zahl handelt

'                               'S' = String   'N' = Number

'           intUpd  as Integer  Soll Zeichen gewechselt werden

'                                0 = Nein   -1 = Ja

'      Out: Umgewandelter Parameter als Rückgabewert der Function

'


On Error GoTo errHandler


  If IsNull(strText) Or Trim(strText) = "" Then

    fktZeichenWechsel = "Null"

  Else

    If intUpd = -1 Then

      Dim i As Integer

      For i = Len(strText) To 1 Step -1

        If Mid(strText, i, 1) = strAlt Then

          strText = left(strText, i - 1) & strNeu & Right(strText, Len(strText) - i)

        End If

      Next i

    End If

    If UCase(strArt) = "S" Then

      fktZeichenWechsel = "'" & strText & "'"

    ElseIf UCase(strArt) = "N" Then

      fktZeichenWechsel = strText

    End If

  End If


exitSubFunktion:

  Exit Function

errHandler:

  MsgBox "Fehler in 'fktZeichenWechsel' " & vbCrLf _

         & Err & ": " & Err.Description, vbExclamation

  Resume exitSubFunktion

End Function

Vielleicht hilft es Euch weiter. Damit kann man entsprechende Einträge für SQL Strings formatieren.

Gruß Meenzer

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.