|
-
Jan 28th, 2014, 11:55 AM
#1
Thread Starter
New Member
adding multiple items to textbox and access database
First, I want to say that I am VERY new to programming. That being said, I have a few questions on an inventory program i am trying to create.
Basically, you scan in a barcode label in a textbox. Click submit button and it displays the item number in a textbox and the lot number in a different textbox. At the same time the item num and lot num get added to the database (ms access).
all of this works, but my question is how can i make this work if i want to scan in multiple barcodes? So everytime submit is clicked, I want it to keep adding to the textboxes and also keep adding to the database. I'm thinking I need a loop someone and probably an array? Any suggestions? Everything is greatly appreciated!! 
Code:
'determine item number from barcode
ItemNo1 = scanTextBox.Text
fint2 = InStr(ItemNo1, "E239", CompareMethod.Text)
ItemNo1 = Mid(scanTextBox.Text, fint2 + 4, fint1 - 6)
TextBox1.Text = ItemNo1
'determine lot number from scanned barcode
LotNo1 = scanTextBox.Text
fint3 = InStr(LotNo1, "$$3", CompareMethod.Text)
LotNo1 = Microsoft.VisualBasic.Mid(scanTextBox.Text, fint3 + 9)
TextLength = Len(LotNo1)
TextBox2.Text = Microsoft.VisualBasic.Left(LotNo1, TextLength - 1)
scanTextBox.Clear()
'run sql statement
selstr = "SELECT TraceLog.Item_Number, TraceLog.Lot_Number, TraceLog.Start_Time, TraceLog.WIF "
selstr = selstr & "FROM TraceLog TraceLog "
sqltext = selstr
rs.Open(sqltext, cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
item_num = TextBox1.Text
lot_num = TextBox2.Text
'add records to database
rs.AddNew()
rs.Fields("Item_Number").Value = item_num
rs.Fields("Lot_Number").Value = lot_num
rs.Fields("Start_Time").Value = Now
rs.Fields("WIF").Value = "1"
rs.Update()
rs.Close()
cn.Close()
rs = Nothing
cn = Nothing
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|