原始输入后,将数据输入自动修剪到Access中的文本框中 [英] Trimming a data entry into a text box in Access automatically after original entry

查看:78
本文介绍了原始输入后,将数据输入自动修剪到Access中的文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Access数据库,该数据库具有通过零件编号标识的图像路径。现在,人们可以手动输入部件号,但我希望他们能够扫描输入部件号的条形码。不幸的是,条形码包含除零件号以外的其他内容。

I have a simple Access database that has image pathways identified by part numbers. Right now people can enter the part number manually but I want them to be able to scan a barcode that enters the part number. Unfortunately, the barcode contains additional content other than the part number.

例如:79 | 99999-ID | Lot:9999 | Exp:1999年6月31日

For example: 79|99999-ID|Lot:9999|Exp:31-June-1999

应该缩小为 99999-ID。

Should be trimmed down to "99999-ID".

Option Explicit  

Private Sub BTN_Search_Click()  
Dim SQL As String  

SQL = "SELECT Query65.ITEM_NUMBER, Query65.PLANNER_DESCRIPTION " _  
    & "From Query65 " _  
    & "WHERE [ITEM_NUMBER] = '" & Me.txtPartNumber & "' " _  
    & "ORDER BY Query65.ITEM_NUMBER "  

Me.SubPlannerSubForm.Form.RecordSource = SQL  
Me.SubPlannerSubForm.Form.Requery  

End Sub```



推荐答案

Public Function SplitBarcodeToPartNo(ByVal Barcode As String) As String
    SplitBarcodeToPartNo = Split(Barcode, "|")(1)
End Function
Private Sub TestSplitBarcodeToPartNo()
    Debug.Print SplitBarcodeToPartNo("79|99999-ID|Lot:9999|Exp:31-June-1999")
End Sub

Split()将字符串分割为 | 并且由于PartNo是第二项,只需按数组索引1来获取它(因为第一项是 Split(Barcode, |)(0),最后一个(日期)是索引3(第四项))

Split()splits the string to an Array at the | and as the PartNo is the second item just fetch it by Array-Index 1 (As the first isSplit(Barcode, "|")(0), Last (Date) is Index 3 (fourth item) )

有没有理由在扫描完所有其他信息后不在数据库中存储其他信息?

Any reason not to store the other infos in the DB as they are scanned allready?

这篇关于原始输入后,将数据输入自动修剪到Access中的文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆