【问题标题】:MS Access Barcode ScanningMS Access 条码扫描
【发布时间】:2018-03-09 21:49:21
【问题描述】:

MS Access 的新手,想知道是否有办法判断扫描的条码是 FedEx 条码还是 UPS 条码。据我所知,UPS 有字母数字条码,FedEx 有 12 位数字条码。我相信这会有所不同。

我想在名为“Type_TrackNum”的表中添加另一列,用于存储标签是 FedEx 还是 UPS。我希望将此附加到 CurrentDB.Execute 命令。

这是我目前所拥有的,只要有前导零,这也会切断前导零,通常在 FedEx 条形码中找到。

Dim strIn As String
Dim i As Integer
Dim iLen As Integer

strIn = Me.txt_Track.Value
iLen = Len(strIn)

For i = 1 To iLen
    If InStr(strIn, "0") = 1 Then
        strIn = Mid(strIn, 2)
    End If
Next i

CurrentDb.Execute _
    "INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
    "VALUES ('" & strIn & "')"

任何帮助都会有所帮助。

【问题讨论】:

  • 代码做你想做的事吗?如果没有,会发生什么 - 错误消息、错误结果,什么都没有?我不知道条形码来源是否可以通过它的结构来确定。
  • 有没有办法说...如果扫描的条形码是字母数字的,那么是ups,如果是数字,那么fedex
  • 一种方式可以很容易地编码为“如果这是数字,那么它就是联邦快递”,反之亦然。问题是,一个字母数字代码可能作为所有数字出现,因此无法保证它会被赋予正确的类别(ups 或 fedex)。
  • 只有在 UPS 总是至少有一个 alpha 而 FedEx 从来没有的情况下。
  • @wazz 如果 UPS 是 12 个字符的随机字母数字条形码,没有任何特殊字符或大写,则它是有效整数的机会 = (10/36)^12 = 2.11*10^- 18.如果您使用的代码少于十亿,我认为这是可以接受的风险。如果您正在使用更多,您可能不应该使用 Access。

标签: ms-access ms-access-2010 ms-access-2013


【解决方案1】:

类似

Dim strIn As String
Dim strType As String 'NEW
Dim i As Integer
Dim iLen As Integer

strIn = Me.txt_Track.Value
iLen = Len(strIn)

If IsNumeric(strIn) Then
    strType = "FedEx"

    For i = 1 To iLen
        If Left(strIn, 1) = "0" Then
            strIn = Mid(strIn, 2)
        Else
            Exit For
        End If
    Next i
Else
    strType = "UPS"
End If

CurrentDb.Execute _
    "INSERT INTO TrackNum_Table(TrackingNum_TrackNum, Type_TrackNum) " & _
    "VALUES ('" & strIn & "', '" & strType & "')"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    相关资源
    最近更新 更多