ทำโปรแกรม POS ด้วย vb6 และฐานข้อมูล access ค่ะ ระหว่างพัฒนา test ผ่านไม่มีปัญหาเลย แต่พอส่งให้ผู้ใช้ ในเครื่องที่ต่างสเปคกัน ปรากฎว่ามีบางวัน ในเอกสารบางใบที่บันทึกรายการให้ไม่ครบ เช่น ขายสินค้า 3 ตัว บันทึกมาได้ 2 ตัว อีกตัวหายจ้อย หรืออาจไม่บันทึกเอกสารนั้นเลย ทั่งๆที่ระหว่างบันทึก ก็ผ่านไม่มีปัญหาอะไรเลย เดือนอาจจะมีสักวัน
เครื่องของผู้ใช้เป็น mainboard ของ win98 แต่ลง win xp ดูเหมือนจะปกติ แต่ผลลัพธ์มันแปลก ตอนนี้กำลังสงสัย hardware และต่อ ลิ้นชัก เครื่องพิมพ์ เครื่องอ่านบาร์โค้ด
ขอความเห็นหน่อยนะคะว่าจะเป็นไปได้หรือเปล่า
รบกวนผู้รู้ทั้งหลายช่วยแนะนำด้วย ของคุณค่ะ
sqlupdate = "SELECT * FROM PFRDATA"
Set rs = DB.OpenRecordset(sqlupdate, dbOpenDynaset)
If rs.RecordCount > 0 Then
rs.Edit
rs!NO_sale = rno
rno = IIf(rno > 9999999, 1, rno + 1)
rs.Update
End If
sqlupdate = "UPDATE PRCACT SET STAT=1 WHERE REFNO='" & txtinv.Text & "'"
DB.Execute (sqlupdate)
Read more ►
เครื่องของผู้ใช้เป็น mainboard ของ win98 แต่ลง win xp ดูเหมือนจะปกติ แต่ผลลัพธ์มันแปลก ตอนนี้กำลังสงสัย hardware และต่อ ลิ้นชัก เครื่องพิมพ์ เครื่องอ่านบาร์โค้ด
ขอความเห็นหน่อยนะคะว่าจะเป็นไปได้หรือเปล่า
รบกวนผู้รู้ทั้งหลายช่วยแนะนำด้วย ของคุณค่ะ
Private Sub CMDPRN_Click()
If saveok = False Then
cmdprn.Enabled = False
Call TCKprn
cmdsave_Click
End If
If saveok = False Then
cmdprn.Enabled = False
Call TCKprn
cmdsave_Click
End If
Private Sub cmdsave_Click()
Dim sqlupdate As String
Dim srvdate As String
Dim I As Integer, rs As Recordset
Dim amtnet As Variant
Dim amtvat As Variant
On Error GoTo 0
If saveok = False Then
saveok = True
Set WRK = DBEngine.Workspaces(0)
cmdsave.Enabled = False
If MSF1.Rows = 2 Then
MsgBox "äÁèÁÕ¢éÍÁÙÅ", vbOKOnly + vbCritical, "¤Óàµ×͹"
Exit Sub
End If
amt7 = 0: amt0 = 0
gact = "ºÑ¹·Ö¡¢éÍÁÙÅ¢ÒÂ" & txtinv.Text
If chkmem.Value = 0 Then mber = " "
WRK.BeginTrans
Dim sqlupdate As String
Dim srvdate As String
Dim I As Integer, rs As Recordset
Dim amtnet As Variant
Dim amtvat As Variant
On Error GoTo 0
If saveok = False Then
saveok = True
Set WRK = DBEngine.Workspaces(0)
cmdsave.Enabled = False
If MSF1.Rows = 2 Then
MsgBox "äÁèÁÕ¢éÍÁÙÅ", vbOKOnly + vbCritical, "¤Óàµ×͹"
Exit Sub
End If
amt7 = 0: amt0 = 0
gact = "ºÑ¹·Ö¡¢éÍÁÙÅ¢ÒÂ" & txtinv.Text
If chkmem.Value = 0 Then mber = " "
WRK.BeginTrans
srvdate = Format(tdate, "dd/mm/yyyy")
amtnet = lblcash.Caption / ((100 + systax) / 100)
amtvat = lblcash.Caption * (systax / (100 + systax))
amtnet = lblcash.Caption / ((100 + systax) / 100)
amtvat = lblcash.Caption * (systax / (100 + systax))
tmpcard = IIf(txtpay.Text > 0, "CS", "CR")
If tmpcard = "CS" Then
TMPCASH = Format(lblcash.Caption, "#####0.00")
xcard = 0
Else
xcard = Format(lblcash.Caption, "#####0.00")
TMPCASH = 0
End If
I = 1
If tmpcard = "CS" Then
TMPCASH = Format(lblcash.Caption, "#####0.00")
xcard = 0
Else
xcard = Format(lblcash.Caption, "#####0.00")
TMPCASH = 0
End If
I = 1
With MSF1
For I = 1 To MSF1.Rows - 2
amtnet = CSng(.TextMatrix(I, 8)) / ((100 + systax) / 100)
If MSF1.TextMatrix(I, 10) = "V" Then
amt7 = amt7 + CCur(MSF1.TextMatrix(I, 8))
Else
amt0 = amt0 + CCur(MSF1.TextMatrix(I, 8))
End If
For I = 1 To MSF1.Rows - 2
amtnet = CSng(.TextMatrix(I, 8)) / ((100 + systax) / 100)
If MSF1.TextMatrix(I, 10) = "V" Then
amt7 = amt7 + CCur(MSF1.TextMatrix(I, 8))
Else
amt0 = amt0 + CCur(MSF1.TextMatrix(I, 8))
End If
sqlupdate = "INSERT INTO detail(refdate,reftype,refno,pcode,refqty,refamt,refprc,REFNET,REFLOT,COUPON,PRC_CHG,refvat7) "
sqlupdate = sqlupdate & "VALUEs('" & srvdate & "','21','"
sqlupdate = sqlupdate & txtinv.Text & "','" & .TextMatrix(I, 1) & "',"
sqlupdate = sqlupdate & CSng(.TextMatrix(I, 7)) & "," & CSng(.TextMatrix(I, 8)) & ","
sqlupdate = sqlupdate & CSng(.TextMatrix(I, 4)) & "," & amtnet & ",'" & .TextMatrix(I, 9) & "',"
sqlupdate = sqlupdate & .TextMatrix(I, 5) & ",'" & PRCCHG & "'," & systax & ")"
DB.Execute (sqlupdate)
Next
End With
sqlupdate = sqlupdate & "VALUEs('" & srvdate & "','21','"
sqlupdate = sqlupdate & txtinv.Text & "','" & .TextMatrix(I, 1) & "',"
sqlupdate = sqlupdate & CSng(.TextMatrix(I, 7)) & "," & CSng(.TextMatrix(I, 8)) & ","
sqlupdate = sqlupdate & CSng(.TextMatrix(I, 4)) & "," & amtnet & ",'" & .TextMatrix(I, 9) & "',"
sqlupdate = sqlupdate & .TextMatrix(I, 5) & ",'" & PRCCHG & "'," & systax & ")"
DB.Execute (sqlupdate)
Next
End With
amtnet = amt7 / ((100 + systax) / 100)
amtvat = amt7 - amtnet
sqlupdate = "INSERT INTO daily(refdate,reftype,refno,refcash,refcard,refdisc1,refamt,refamt7,refamt0,refmem,refsman,cashier,refno2,"
sqlupdate = sqlupdate & "refdisc2,refdisc3,reftime,refnet,refvat,reftot,refflag,refclr)"
sqlupdate = sqlupdate & " VALUEs('" & srvdate & "','21','"
sqlupdate = sqlupdate & txtinv.Text & "'," & TMPCASH & ",'" & tmpcard & "'," & Format(lbldsc.Caption, "#0") & ","
sqlupdate = sqlupdate & Format(TT, "#####0.00") & "," & Format(amt7, "#####0.00") & "," & Format(amt0, "#####0.00") & ",'" & mber & "','" & chkid & "','" & gpass & "',' ',0,0,'" & Time() & "',"
sqlupdate = sqlupdate & Format(amtnet, "#####0.00") & "," & Format(amtvat, "#####0.00") & "," & Format(lblcash.Caption, "#####0.00") & ",0,0)"
DB.Execute (sqlupdate)
amtvat = amt7 - amtnet
sqlupdate = "INSERT INTO daily(refdate,reftype,refno,refcash,refcard,refdisc1,refamt,refamt7,refamt0,refmem,refsman,cashier,refno2,"
sqlupdate = sqlupdate & "refdisc2,refdisc3,reftime,refnet,refvat,reftot,refflag,refclr)"
sqlupdate = sqlupdate & " VALUEs('" & srvdate & "','21','"
sqlupdate = sqlupdate & txtinv.Text & "'," & TMPCASH & ",'" & tmpcard & "'," & Format(lbldsc.Caption, "#0") & ","
sqlupdate = sqlupdate & Format(TT, "#####0.00") & "," & Format(amt7, "#####0.00") & "," & Format(amt0, "#####0.00") & ",'" & mber & "','" & chkid & "','" & gpass & "',' ',0,0,'" & Time() & "',"
sqlupdate = sqlupdate & Format(amtnet, "#####0.00") & "," & Format(amtvat, "#####0.00") & "," & Format(lblcash.Caption, "#####0.00") & ",0,0)"
DB.Execute (sqlupdate)
sqlupdate = "UPDATE CASH SET CIOCARD=IIF(ISNULL(CIOCARD),0,CIOCARD)+" & xcard & ",CIOSALE=IIF(ISNULL(CIOSALE),0,CIOSALE)+" & TMPCASH
sqlupdate = sqlupdate + " WHERE CIODA=#" & ADATE & "# AND CIOCLR=0"
DB.Execute (sqlupdate)
'End With
sqlupdate = sqlupdate + " WHERE CIODA=#" & ADATE & "# AND CIOCLR=0"
DB.Execute (sqlupdate)
'End With
sqlupdate = "SELECT * FROM PFRDATA"
Set rs = DB.OpenRecordset(sqlupdate, dbOpenDynaset)
If rs.RecordCount > 0 Then
rs.Edit
rs!NO_sale = rno
rno = IIf(rno > 9999999, 1, rno + 1)
rs.Update
End If
sqlupdate = "UPDATE PRCACT SET STAT=1 WHERE REFNO='" & txtinv.Text & "'"
DB.Execute (sqlupdate)
WRK.CommitTrans
MsgBox "ºÑ¹·Ö¡àÍ¡ÊÒà # " + txtinv.Text + " àÃÕºÃéÍÂáÅéÇ", vbOKOnly + vbInformation, "¼Å¡Ò÷ӧҹ"
Call clrdata
End If
End Sub
MsgBox "ºÑ¹·Ö¡àÍ¡ÊÒà # " + txtinv.Text + " àÃÕºÃéÍÂáÅéÇ", vbOKOnly + vbInformation, "¼Å¡Ò÷ӧҹ"
Call clrdata
End If
End Sub
Private Sub TCKprn()
Dim rh As Integer
Dim YPS As Integer
Dim I As Integer, X As Integer
Dim K As Integer, amt As Currency
Dim F1 As Integer, F2 As Integer, L1 As Integer
If saveok = False Then
cmdprn.Enabled = False
gact = "¾ÔÁ¾ì¢éÍÁÙÅ¢Ò " & txtinv.Text
tmpcard = IIf(txtpay.Text > 0, "CS", "CR")
CPdsc = False
Dim rh As Integer
Dim YPS As Integer
Dim I As Integer, X As Integer
Dim K As Integer, amt As Currency
Dim F1 As Integer, F2 As Integer, L1 As Integer
If saveok = False Then
cmdprn.Enabled = False
gact = "¾ÔÁ¾ì¢éÍÁÙÅ¢Ò " & txtinv.Text
tmpcard = IIf(txtpay.Text > 0, "CS", "CR")
CPdsc = False
If MSF1.Rows = 2 Then
' MsgBox "äÁèÁÕ¢éÍÁÙÅ", vbOKOnly + vbCritical, "¤Óàµ×͹"
Exit Sub
End If
' MsgBox "äÁèÁÕ¢éÍÁÙÅ", vbOKOnly + vbCritical, "¤Óàµ×͹"
Exit Sub
End If
For X = 1 To systck
If SYSPRN = "DOT" Then
SetDefaultPrinter ("Epson TM-U950 Partial cut")
If X = 2 Then
Printer.FontName = "control"
Printer.Print "1" '1=JOURNAL
Else
Printer.FontName = "control"
Printer.Print "2" '2=RECEIVE
If comdraw = True Then
DoEvents
Open "LPT1" For Output Access Write As #1 'à´é§ÅÔ鹪ѡ
Print #1, Chr$(27); Chr$(112); Chr$(0)
Close #1
DoEvents
' Printer.FontName = "control"
' Printer.Print "A"
End If
End If
amt = 0
' End If
F1 = 11
F2 = 14
L1 = 3400
Else
SetDefaultPrinter ("BTPTML")
F1 = 11
F2 = 8
L1 = 3500
End If
YPS = 50
With Printer
'.PaperBin = Default
' .FontName = "cordiaUPC"
If SYSPRN = "DOT" Then
' .FontName = "dilleniaDSE"
.FontName = "ms sans serif"
Else
.FontName = "ms sans serif"
End If
.FontSize = 11
.FontBold = True
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 60
.CurrentY = YPS
Printer.Print tid
.FontBold = False
.FontSize = F2
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 50
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
.CurrentY = 400
Printer.Print "POS#" + SYSPOS + " TAX#" + TAXID
.FontName = "dilleniaDSE"
.FontSize = F1
Else
.CurrentY = 300
Printer.Print "POS# " + SYSPOS + " TAX# " + TAXID
End If
SetDefaultPrinter ("Epson TM-U950 Partial cut")
If X = 2 Then
Printer.FontName = "control"
Printer.Print "1" '1=JOURNAL
Else
Printer.FontName = "control"
Printer.Print "2" '2=RECEIVE
If comdraw = True Then
DoEvents
Open "LPT1" For Output Access Write As #1 'à´é§ÅÔ鹪ѡ
Print #1, Chr$(27); Chr$(112); Chr$(0)
Close #1
DoEvents
' Printer.FontName = "control"
' Printer.Print "A"
End If
End If
amt = 0
' End If
F1 = 11
F2 = 14
L1 = 3400
Else
SetDefaultPrinter ("BTPTML")
F1 = 11
F2 = 8
L1 = 3500
End If
YPS = 50
With Printer
'.PaperBin = Default
' .FontName = "cordiaUPC"
If SYSPRN = "DOT" Then
' .FontName = "dilleniaDSE"
.FontName = "ms sans serif"
Else
.FontName = "ms sans serif"
End If
.FontSize = 11
.FontBold = True
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 60
.CurrentY = YPS
Printer.Print tid
.FontBold = False
.FontSize = F2
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 50
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
.CurrentY = 400
Printer.Print "POS#" + SYSPOS + " TAX#" + TAXID
.FontName = "dilleniaDSE"
.FontSize = F1
Else
.CurrentY = 300
Printer.Print "POS# " + SYSPOS + " TAX# " + TAXID
End If
.CurrentX = 50
.CurrentY = YPS + (rh * 2)
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
Printer.Print "DATE : " + tdate + " RCPT # " + txtinv.Text
'.FontName = "dilleniaDSE"
.FontName = "MS Sans Serif"
' .FontSize = 9
Else
Printer.Print "DATE : " + tdate + " RCPT # " + txtinv.Text
End If
.CurrentX = 50
.CurrentY = YPS + (rh * 3)
If SYSPRN = "DOT" Then
Printer.Print " RECEIPT/TAX INVOICE (ABB.)"
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(40, "_")
Else
Printer.Print " RECEIPT/TAX INVOICE (ABB.)"
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(44, "_")
End If
K = 5
I = 1
' With MSF1
For I = 1 To MSF1.Rows - 2
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
'Printer.Print IIf(Left(MSF1.TextMatrix(I, 2), 1) = "[", Mid(MSF1.TextMatrix(I, 2), 4, 12), Mid(MSF1.TextMatrix(I, 2), 1, 12))
Printer.Print Left(MSF1.TextMatrix(I, 2), 12)
If MSF1.TextMatrix(I, 7) > 1 Or MSF1.TextMatrix(I, 5) > 0 Then
.CurrentX = 1800 - .TextWidth(Format(MSF1.TextMatrix(I, 4), "##,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print "@" & Format(MSF1.TextMatrix(I, 4), "##,##0.00")
If MSF1.TextMatrix(I, 5) > 0 Then CPdsc = True
End If
.CurrentX = 2300 - .TextWidth(Format(MSF1.TextMatrix(I, 7), "#,###"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(MSF1.TextMatrix(I, 7), "#,###")
'+ " " + MSF1.TextMatrix(I, 9)
.CurrentX = L1 - .TextWidth(Format(MSF1.TextMatrix(I, 8), "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
'Printer.Print Format(MSF1.TextMatrix(I, 7) * MSF1.TextMatrix(I, 4), "###,##0.00")
'amt = amt + (MSF1.TextMatrix(I, 7) * MSF1.TextMatrix(I, 4))
Printer.Print Format(MSF1.TextMatrix(I, 8), "###,##0.00")
amt = amt + (MSF1.TextMatrix(I, 8))
K = K + 1
Next
' End With
.FontBold = True
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "TOTAL"
.CurrentX = L1 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(amt, "###,##0.00")
.CurrentY = YPS + (rh * 2)
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
Printer.Print "DATE : " + tdate + " RCPT # " + txtinv.Text
'.FontName = "dilleniaDSE"
.FontName = "MS Sans Serif"
' .FontSize = 9
Else
Printer.Print "DATE : " + tdate + " RCPT # " + txtinv.Text
End If
.CurrentX = 50
.CurrentY = YPS + (rh * 3)
If SYSPRN = "DOT" Then
Printer.Print " RECEIPT/TAX INVOICE (ABB.)"
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(40, "_")
Else
Printer.Print " RECEIPT/TAX INVOICE (ABB.)"
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(44, "_")
End If
K = 5
I = 1
' With MSF1
For I = 1 To MSF1.Rows - 2
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
'Printer.Print IIf(Left(MSF1.TextMatrix(I, 2), 1) = "[", Mid(MSF1.TextMatrix(I, 2), 4, 12), Mid(MSF1.TextMatrix(I, 2), 1, 12))
Printer.Print Left(MSF1.TextMatrix(I, 2), 12)
If MSF1.TextMatrix(I, 7) > 1 Or MSF1.TextMatrix(I, 5) > 0 Then
.CurrentX = 1800 - .TextWidth(Format(MSF1.TextMatrix(I, 4), "##,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print "@" & Format(MSF1.TextMatrix(I, 4), "##,##0.00")
If MSF1.TextMatrix(I, 5) > 0 Then CPdsc = True
End If
.CurrentX = 2300 - .TextWidth(Format(MSF1.TextMatrix(I, 7), "#,###"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(MSF1.TextMatrix(I, 7), "#,###")
'+ " " + MSF1.TextMatrix(I, 9)
.CurrentX = L1 - .TextWidth(Format(MSF1.TextMatrix(I, 8), "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
'Printer.Print Format(MSF1.TextMatrix(I, 7) * MSF1.TextMatrix(I, 4), "###,##0.00")
'amt = amt + (MSF1.TextMatrix(I, 7) * MSF1.TextMatrix(I, 4))
Printer.Print Format(MSF1.TextMatrix(I, 8), "###,##0.00")
amt = amt + (MSF1.TextMatrix(I, 8))
K = K + 1
Next
' End With
.FontBold = True
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "TOTAL"
.CurrentX = L1 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(amt, "###,##0.00")
K = K + 1
If MMDSC > 0 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "DISC " & MMDSC & "%"
.CurrentX = L1 - .TextWidth(Format(xdsc, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(xdsc, "###,##0.00")
K = K + 1
.CurrentX = 700
.CurrentY = YPS + (rh * K + 1)
Printer.Print "NET CASH"
.CurrentX = L1 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblcash.Caption, "###,##0.00")
K = K + 1
End If
If tmpcard = "CS" Then
.CurrentX = IIf(MMDSC > 0, 700, 500)
.CurrentY = YPS + (rh * K + 1)
Printer.Print "CASH"
.CurrentX = L1 - .TextWidth(Format(txtpay.Text, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(txtpay.Text, "###,##0.00")
Else
.CurrentX = IIf(MMDSC > 0, 700, 500)
.CurrentY = YPS + (rh * K + 1)
Printer.Print "CR " + cmbcard.Text
.CurrentX = L1 - .TextWidth(Format(lblcash.Caption, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblcash.Caption, "###,##0.00")
End If
K = K + 1
'If optcash.Value = True Then
If tmpcard = "CS" Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print " CHANGE"
'.FontBold = True
.CurrentX = L1 - .TextWidth(Format(lblton.Caption, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblton.Caption, "###,##0.00")
.FontBold = False
K = K + 1
End If
If chkmem.Value = 1 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "MEM. " + txtno.Text
K = K + 1
End If
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print String(40, "=")
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print sysmess
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print IIf(SYSPRN = "DOT", Time() & " *VAT INCLUDED*", Time() & " *VAT INCLUDED*")
K = K + 1
'.CurrentX = IIf(SYSPRN = "DOT", 2200, 3000)
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print "RCVD BY : " + sayname
.EndDoc
End With
Next
If CPdsc = True Then CP_PRN
End If
End Sub
If MMDSC > 0 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "DISC " & MMDSC & "%"
.CurrentX = L1 - .TextWidth(Format(xdsc, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(xdsc, "###,##0.00")
K = K + 1
.CurrentX = 700
.CurrentY = YPS + (rh * K + 1)
Printer.Print "NET CASH"
.CurrentX = L1 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblcash.Caption, "###,##0.00")
K = K + 1
End If
If tmpcard = "CS" Then
.CurrentX = IIf(MMDSC > 0, 700, 500)
.CurrentY = YPS + (rh * K + 1)
Printer.Print "CASH"
.CurrentX = L1 - .TextWidth(Format(txtpay.Text, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(txtpay.Text, "###,##0.00")
Else
.CurrentX = IIf(MMDSC > 0, 700, 500)
.CurrentY = YPS + (rh * K + 1)
Printer.Print "CR " + cmbcard.Text
.CurrentX = L1 - .TextWidth(Format(lblcash.Caption, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblcash.Caption, "###,##0.00")
End If
K = K + 1
'If optcash.Value = True Then
If tmpcard = "CS" Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print " CHANGE"
'.FontBold = True
.CurrentX = L1 - .TextWidth(Format(lblton.Caption, "###,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(lblton.Caption, "###,##0.00")
.FontBold = False
K = K + 1
End If
If chkmem.Value = 1 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "MEM. " + txtno.Text
K = K + 1
End If
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print String(40, "=")
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print sysmess
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print IIf(SYSPRN = "DOT", Time() & " *VAT INCLUDED*", Time() & " *VAT INCLUDED*")
K = K + 1
'.CurrentX = IIf(SYSPRN = "DOT", 2200, 3000)
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print "RCVD BY : " + sayname
.EndDoc
End With
Next
If CPdsc = True Then CP_PRN
End If
End Sub
Private Sub CP_PRN()
Dim rh As Integer
Dim YPS As Integer
Dim I As Integer, X As Integer
Dim K As Integer, amt As Currency
Dim F1 As Integer, F2 As Integer, L1 As Integer
tmpcard = IIf(txtpay.Text > 0, "CS", "CR")
For X = 1 To 2
Dim rh As Integer
Dim YPS As Integer
Dim I As Integer, X As Integer
Dim K As Integer, amt As Currency
Dim F1 As Integer, F2 As Integer, L1 As Integer
tmpcard = IIf(txtpay.Text > 0, "CS", "CR")
For X = 1 To 2
If SYSPRN = "DOT" Then
SetDefaultPrinter ("Epson TM-U950 Partial cut")
If X = 2 Then
Printer.FontName = "control"
Printer.Print "1"
Else
Printer.FontName = "control"
Printer.Print "2"
If comdraw = True Then
'DoEvents
'Open "LPT1" For Output Access Write As #1 'à´é§ÅÔ鹪ѡ
'Print #1, Chr$(27); Chr$(112); Chr$(0)
'Close #1
' DoEvents
End If
End If
amt = 0
F1 = 11
F2 = 14
L1 = 3400
Else
SetDefaultPrinter ("BTPTML")
F1 = 11
F2 = 8
L1 = 3500
End If
YPS = 50
With Printer
If SYSPRN = "DOT" Then
' .FontName = "dilleniaDSE"
.FontName = "ms sans serif"
Else
.FontName = "ms sans serif"
End If
.FontSize = 14
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 60
.CurrentY = YPS
Printer.Print tid
.FontBold = False
.FontSize = F2
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 50
.CurrentY = 400
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
Printer.Print "DATE : " & Format(tdate, "dd/mm/yyyy")
.FontName = "MS Sans Serif"
Else
Printer.Print "DATE : " + tdate
End If
.CurrentX = 50
.CurrentY = YPS + (rh * 2)
Printer.Print "INVOICE : " + txtinv.Text + " ¨Ó¹Ç¹à§Ô¹ " & lblcash.Caption
.CurrentX = 50
.FontSize = 14
rh = .TextHeight("·´Êͺ") + 2
.CurrentY = YPS + (rh * 3)
If SYSPRN = "DOT" Then
Printer.Print " ÃÒ¡ÒÃãËéÊèǹŴ¤Ù»Í§"
Else
Printer.Print " ÃÒ¡ÒÃãËéÊèǹŴ¤Ù»Í§"
End If
.FontSize = 9
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(40, "_")
K = 5
I = 1
For I = 1 To MSF1.Rows - 2
If MSF1.TextMatrix(I, 5) > 0 Then
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print Left(MSF1.TextMatrix(I, 2), 20)
SetDefaultPrinter ("Epson TM-U950 Partial cut")
If X = 2 Then
Printer.FontName = "control"
Printer.Print "1"
Else
Printer.FontName = "control"
Printer.Print "2"
If comdraw = True Then
'DoEvents
'Open "LPT1" For Output Access Write As #1 'à´é§ÅÔ鹪ѡ
'Print #1, Chr$(27); Chr$(112); Chr$(0)
'Close #1
' DoEvents
End If
End If
amt = 0
F1 = 11
F2 = 14
L1 = 3400
Else
SetDefaultPrinter ("BTPTML")
F1 = 11
F2 = 8
L1 = 3500
End If
YPS = 50
With Printer
If SYSPRN = "DOT" Then
' .FontName = "dilleniaDSE"
.FontName = "ms sans serif"
Else
.FontName = "ms sans serif"
End If
.FontSize = 14
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 60
.CurrentY = YPS
Printer.Print tid
.FontBold = False
.FontSize = F2
rh = .TextHeight("·´Êͺ") + 2
.CurrentX = 50
.CurrentY = 400
If SYSPRN = "DOT" Then
.FontName = "TAHOMA"
.FontSize = 9
Printer.Print "DATE : " & Format(tdate, "dd/mm/yyyy")
.FontName = "MS Sans Serif"
Else
Printer.Print "DATE : " + tdate
End If
.CurrentX = 50
.CurrentY = YPS + (rh * 2)
Printer.Print "INVOICE : " + txtinv.Text + " ¨Ó¹Ç¹à§Ô¹ " & lblcash.Caption
.CurrentX = 50
.FontSize = 14
rh = .TextHeight("·´Êͺ") + 2
.CurrentY = YPS + (rh * 3)
If SYSPRN = "DOT" Then
Printer.Print " ÃÒ¡ÒÃãËéÊèǹŴ¤Ù»Í§"
Else
Printer.Print " ÃÒ¡ÒÃãËéÊèǹŴ¤Ù»Í§"
End If
.FontSize = 9
.CurrentX = 0
.CurrentY = YPS + (rh * 4)
Printer.Print String(40, "_")
K = 5
I = 1
For I = 1 To MSF1.Rows - 2
If MSF1.TextMatrix(I, 5) > 0 Then
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print Left(MSF1.TextMatrix(I, 2), 20)
.CurrentX = 3000 - .TextWidth(Format(MSF1.TextMatrix(I, 5), "##,##0.00"))
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(MSF1.TextMatrix(I, 5), "##,##0.00") & " ºÒ·"
amt = amt + (MSF1.TextMatrix(I, 5))
K = K + 1
End If
Next
.CurrentX = 500
.CurrentY = YPS + (rh * K)
Printer.Print "TOTAL"
.CurrentX = 3000 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K)
Printer.Print Format(amt, "###,##0.00")
K = K + 1
If chkmem.Value = 1 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "MEM. " + txtno.Text
K = K + 1
End If
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print String(40, "=")
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print Time() & " RCVD BY : " & sayname
.EndDoc
End With
Next
End Sub
.CurrentY = YPS + (rh * K + 1)
Printer.Print Format(MSF1.TextMatrix(I, 5), "##,##0.00") & " ºÒ·"
amt = amt + (MSF1.TextMatrix(I, 5))
K = K + 1
End If
Next
.CurrentX = 500
.CurrentY = YPS + (rh * K)
Printer.Print "TOTAL"
.CurrentX = 3000 - .TextWidth(Format(amt, "###,##0.00"))
.CurrentY = YPS + (rh * K)
Printer.Print Format(amt, "###,##0.00")
K = K + 1
If chkmem.Value = 1 Then
.CurrentX = 500
.CurrentY = YPS + (rh * K + 1)
Printer.Print "MEM. " + txtno.Text
K = K + 1
End If
.CurrentX = 0
.CurrentY = YPS + (rh * K + 1)
Printer.Print String(40, "=")
K = K + 1
.CurrentX = 50
.CurrentY = YPS + (rh * K + 1)
Printer.Print Time() & " RCVD BY : " & sayname
.EndDoc
End With
Next
End Sub
======================
ปัญหาคล้ายๆแบบนี้ที่ผ่านก็พบว่าเครื่องที่เราใช้พัฒนาเป็น ACCESS เวอร์ชั่นที่สูงกว่าเครื่องผู้ใช้งานน่ะครับ หรือไม่ก็เอาโค้ดมาโพสให้สมาชิกช่วยกันหาวิธีแก้ไขก็ได้นะครับ |
คิดว่าเจอปัญหาแล้วหละ คงเพราะวิธีการเปิด connection แบบ DAO กับ ADO ลองเปลี่ยนใช้ ADO ดู คาดว่าคงผ่าน ได้ผลแบบไหนแล้วจะ post บอกนะคะ
อธิบายปัญหาเพิ่มเติม เริ่มจาก บันทึกข้อมูล แล้วมีข้อความ run-time error -2147467259(80004005) Could not update;currently locked. ดูไปดูมาได้ความว่าเป็น bug ของ ms ให้แก้ด้วยวิธีเปลื่ยนการ connect จาก ms ole provider for jet 4.0 เป็น ms oledb provider for odbc drivers(MSDASQL) WITH the ms access dirver แบบ MSDASQL คือ cn.open "provider=MSDASQL.1;dbq= access driver (*.mdb)}" แบบ jet 4.0 คือ cn.open "provider=microsoft.jet.oledb.4.0;data source= |
แปลก ผมเจอกับ access link to sql server 2005 ไปเซ็ท permission และเช็คทุก table index หายต้องเซ็ทใหม่ |