MS Access で、テキスト フィールドの最後の 4 つの位置をインクリメントするコードを設定しようとしています。テキスト フィールドの数字は 7 桁です。例えば:
0010012
0010013
最初の 3 桁はメーカーを表し、最後の 4 桁は製品を表します。これらは私が増やしたいものです。オンラインで見つけた以下のコードを使用しています。動作するはずですが、「実行時エラー '13': タイプが一致しません」というエラーが表示され続けます。
Dim varSifra As Variant
varSifra = DMax("[Sifra]", "tblProducts", "[Manufacturer] = " & Forms!frmProduct!Manufacturer)
Me.[Sifra] = Left(varSifra, 3) & Format(Val(Right(varSifra, 4)) + 1, "0000")
Format 関数を使用せずにコードを試してみましたが、インクリメントされた数値 0010014 の代わりに 00114 が返されました