Page 1 of 1
Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Wed Oct 13, 2021 5:58 pm
by Bigtongchai17
ช่วยด้วยครับ
- Sheet Picker Scan เมื่อ Scan ในช่อง Tag ลูกค้า แล้วให้บันทึกข้อมูลใน Sheet Scan Data ใน Column B ไปเรื่อยๆ ทุกครั้งที่สแกน
- Sheet Picker Scan เมื่อ Scan ในช่อง Part No แล้วให้บันทึกข้อมูลใน Sheet Scan Data ใน Column B ไปเรื่อยๆ ทุกครั้งที่สแกน
New ตรวจสอบNew V.3.xlsm
Re: Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Wed Oct 13, 2021 6:35 pm
by snasui

ตัวอย่างการปรับ Code ตามด้านล่างครับ
Code: Select all
Private Sub txtorder_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim lstRw As Long
If KeyCode = 13 Then 'Or KeyCode = 9 Then
'txtWave.Activate
If ValidateForm Then
With Worksheets("Scan Data")
lstRw = .Range("b" & .Rows.Count).End(xlUp).Row + 1
.Range("b" & lstRw).Value = Me.txtWave.Value
.Range("c" & lstRw).Value = Me.txtorder.Value
End With
End If
End If
End Sub
กรณีที่ยังไม่ตรงกับความต้องการ กรุณาอธิบายวิธีการทำงานพร้อมวิธีทดสอบมาอย่างละเอียดพร้อมปรับปรุง Code มาเองก่อนเสมอ ติดตรงไหนค่อยถามกันต่อครับ
Re: Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Mon Nov 08, 2021 9:59 am
by Bigtongchai17
เมื่อ Scan ในช่อง Part No เรียบร้อยแล้วจะให้กลับไปที่ช่อง Tag ลูกค้า เพื่อสแกนค่าใหม่ จะต้องทำอย่างไรครับ
Re: Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Mon Nov 08, 2021 5:34 pm
by snasui

กรุณาเขียน Code ให้ทำงานนั้นมาด้วยตนเองก่อน ติดปัญหาตรงไหนค่อยนำมาถามกันต่อครับ
Re: Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Fri Nov 12, 2021 11:25 am
by Bigtongchai17
ผมลองเขียน Code มาแล้วครับ แต่พอ Scan ถึงช่อง Part No. Cursor มันไม่เด้งกลับไปที่ช่อง Tag ลูกค้า เพื่อทำการ Scan ต่อครับ
Concept
ทำการ Scan ที่ช่อง Tag ลุกค้า จากนั้นให้ Auto Enter ไปที่ช่อง Part No. จากนั้นให้ Auto บันทึกข้อมูลใน Sheet "Scan Data" และให้ CurSor Auto Enter กับไปที่่ช่อง Tag ลูกค้า วนไปเรือยๆครับ
Option Explicit
Function ValidateForm() As Boolean
txtWave.BackColor = vbWhite
txtorder.BackColor = vbWhite
ValidateForm = True
If Trim(txtWave.Value) = "" Then
MsgBox " Confirm?", vbOKOnly + vbInformation, "Wave"
txtWave.BackColor = vbRed
txtWave.Activate
ValidateForm = False
ElseIf Trim(txtorder.Value) = "" Then
MsgBox " order can't be left blank.", vbOKOnly + vbInformation, "Order"
txtorder.BackColor = vbRed
txtorder.Activate
ValidateForm = False
End If
End Function
Private Sub txtWave_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Or KeyCode = 9 Then
txtorder.Activate
End If
End Sub
Function Reset()
Application.ScreenUpdating = False
txtWave.Value = ""
txtWave.BackColor = vbWhite
txtorder.Value = ""
txtorder.BackColor = vbWhite
Application.ScreenUpdating = True
End Function
Private Sub cmdReset_Click()
Dim i As Integer
i = MsgBox("Do you want reset?", vbQuestion + vbYesNo + vbDefaultButton2, "Form Reset")
If i = vbYes Then
Call Reset
End If
End Sub
Private Sub txtorder_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Application.ScreenUpdating = False
Dim iRow As Long
If KeyCode = 13 Then 'Or KeyCode = 9 Then
'txtWave.Activate
iRow = Sheets("Scan Data").Range("A1048576").End(xlUp).Row + 1
If ValidateForm = True Then
With ThisWorkbook.Sheets("Scan Data")
.Range("A" & iRow).Value = iRow - 1
.Range("B" & iRow).Value = txtWave.Value
.Range("C" & iRow).Value = txtorder.Value
End With
Call Reset
Else
If KeyCode = 13 Then 'Or KeyCode = 9 Then
'txtOrder.Activate
End If
Exit Sub
End If
Application.ScreenUpdating = True
End If
End Sub
Re: Scan Barcode แล้วให้บันทึกไปอีก Sheet
Posted: Fri Nov 12, 2021 7:12 pm
by snasui

กรุณาปรับ Code ให้แสดงเป็น Code ตามตัวอย่างในกฎการใช้บอร์ดข้อ 5 ด้านบน

พร้อมแนบไฟล์ประกอบมาด้วย จะได้ในการตอบของเพื่อนสมาชิกครับ