hello please help me on my problem how to trap in my grd if the user forgot to input the quantity then it will display the messagebox "sorry you forgot to input the quantity"...i already try to trap but
only in the first rows,...but i don't know how to trap if i am in the 2nd rows,3rd rows or etc....please help me how to trap if the user forget to input the quantity...please look in my the txtqty_keyDown..
also how to trap if my mch_qtyh is already zero...then if the user will input in the txtmchno_keydown ...example this mchno R1010 is already zero if the user input this..it will display msgbox"this mchno quantity on hand is already zero"..pease help me how to do this.. how can i trap this...thanks in advance hoping for your positive responds...
here's my code
Public con As ADODB.Connection
Public cmd As ADODB.Command
Public mch_rs As ADODB.Recordset
Public order_rs As ADODB.Recordset
Public cust_rs As ADODB.Recordset
Public od_rs As ADODB.Recordset
Public sql As String
Public m_cno As String
Public m_orno As String, m_amt As String
Public amount As Double, sum As Double
Private Sub txtcno_Click()
header
txtcno.Text = ""
lblorno.Caption = ""
lbldate.Caption = ""
lblname.Caption = ""
lbladdress.Caption = ""
lbltelno.Caption = ""
txtcno.Locked = False
If order_rs.State = adStateOpen Then
order_rs.Close
End If
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdfirst_Click()
If Trim(lblname.Caption) = "" Then
MsgBox "You have not inputed the customer number", vbExclamation, "Input customer number"
Call highlight(txtcno)
Exit Sub
End If
If order_rs.BOF = True And order_rs.EOF = True Then
MsgBox "Sorry this customer is no order", vbExclamation, "Input another customer"
Call highlight(txtcno)
Exit Sub
Else
order_rs.MoveFirst
display_slipno
End If
End Sub
Private Sub cmdlast_Click()
If Trim(lblname.Caption) = "" Then
MsgBox "You have not inputed the customer number", vbExclamation, "Input customer number"
Call highlight(txtcno)
Exit Sub
End If
If order_rs.BOF = True And order_rs.EOF = True Then
MsgBox "Sorry this customer is no order", vbExclamation, "Input another customer"
Call highlight(txtcno)
Exit Sub
Else
order_rs.MoveLast
display_slipno
End If
End Sub
Private Sub cmdnext_Click()
If Trim(lblname.Caption) = "" Then
MsgBox "You have not inputed the customer number", vbExclamation, "Input customer number"
Call highlight(txtcno)
Exit Sub
End If
If order_rs.EOF = False Then
order_rs.MoveNext
display_slipno
Else
MsgBox "No more orders can be found", vbCritical, "OOops!!!..Sorry!!"
Exit Sub
End If
End Sub
Private Sub cmdprevious_Click()
If Trim(lblname.Caption) = "" Then
MsgBox "You have not inputed the customer number", vbExclamation, "Input customer number"
Call highlight(txtcno)
Exit Sub
End If
If order_rs.BOF = False Then
order_rs.MovePrevious
display_slipno
Else
MsgBox "No more orders can be found", vbCritical, "OOops!!!..Sorry!!"
Exit Sub
End If
End Sub
Private Sub txtcno_KeyDown(KeyCode As Integer, Shift As Integer)
If order_rs.State = adStateOpen Then
order_rs.Close
End If
m_cno = Trim(txtcno.Text)
If KeyCode = 13 Then
sql = "select * from customer_table where cust_no = '" & m_cno & "'"
Set cust_rs = con.Execute(sql)
If cust_rs.BOF = True And cust_rs.EOF = True Then
MsgBox "Sorry" + " " + m_cno + " " + "not found in the customer table", vbCritical
Exit Sub
Else
lblname.Caption = cust_rs!cust_name
lbladdress.Caption = cust_rs!cust_address
lbltelno.Caption = cust_rs!cust_telno
sql = "select * from order_table where order_custno = '" & m_cno & "'order by order_slipno asc,order_date asc"
order_rs.Open sql, con, adOpenStatic
txtcno.Locked = True
End If
cust_rs.Close
End If
End Sub
Private Sub display_slipno()
If order_rs.BOF = True Or order_rs.EOF = True Then
MsgBox "Sorry no order slip found", vbInformation, "End of File"
Exit Sub
Else
lblorno.Caption = order_rs!order_slipno
lbldate.Caption = order_rs!order_date
display_detail
End If
End Sub
Private Sub display_detail()
sql = "select * from order_detail_table where od_orslipno = '" & order_rs!order_slipno & "'"
Set od_rs = con.Execute(sql)
If od_rs.BOF = True And od_rs.EOF = True Then
MsgBox "Sorry Order Slip No...not found id order detail table'"
Exit Sub
Else
Display
End If
od_rs.Close
End Sub
Private Sub Display()
sum = 0
od_rs.MoveFirst
header
Do Until od_rs.EOF = True
With grd
.TextMatrix(grd.Rows - 1, 0) = od_rs!od_seqno
.TextMatrix(grd.Rows - 1, 1) = od_rs!od_mchno
.TextMatrix(grd.Rows - 1, 4) = od_rs!od_qty
.TextMatrix(grd.Rows - 1, 5) = od_rs!od_uprice
End With
amount = od_rs!od_qty * od_rs!od_uprice
sum = sum + amount
grd.TextMatrix(grd.Rows - 1, 6) = Format(amount, "#,##.00.0")
display2
grd.Rows = grd.Rows + 1
od_rs.MoveNext
Loop
grd.Rows = grd.Rows + 1
grd.TextMatrix(grd.Rows - 1, 5) = "Total :"
grd.TextMatrix(grd.Rows - 1, 6) = Format(sum, "#,##.00.0")
End Sub
Private Sub display2()
sql = "select * from merchandise_table where mch_no = '" & od_rs!od_mchno & "'"
Set mch_rs = con.Execute(sql)
If mch_rs.BOF = True And mch_rs.EOF = True Then
grd.TextMatrix(grd.Rows - 1, 2) = "MERCHANDISE"
grd.TextMatrix(grd.Rows - 1, 3) = "NOT FOUND"
Exit Sub
Else
grd.TextMatrix(grd.Rows - 1, 2) = mch_rs!mch_name
grd.TextMatrix(grd.Rows - 1, 3) = mch_rs!mch_umsr
End If
mch_rs.Close
End Sub
Public Sub header()
grd.clear
grd.Rows = 2
grd.Cols = 7
grd.ColWidth(2) = 3000
grd.ColWidth(3) = 1500
grd.ColWidth(5) = 1500
grd.ColWidth(6) = 1500
With grd
.TextMatrix(0, 0) = "seqno"
.TextMatrix(0, 1) = "mchno"
.TextMatrix(0, 2) = "merchandise name"
.TextMatrix(0, 3) = "umsr"
.TextMatrix(0, 4) = "qty"
.TextMatrix(0, 5) = "uprice"
.TextMatrix(0, 6) = "amount"
End With
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
Set cmd = New ADODB.Command
Set mch_rs = New ADODB.Recordset
Set cust_rs = New ADODB.Recordset
Set order_rs = New ADODB.Recordset
Set od_rs = New ADODB.Recordset
With con
.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\project.mdb"
.Open
End With
header
End Sub
Public Function highlight(txt As TextBox)
With txt
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End Function
Public Function txtboxtrap(KeyAscii As Integer)
If KeyAscii >= 33 And KeyAscii <= 44 Or KeyAscii = 45 Or KeyAscii = 46 Or KeyAscii = 47 Or KeyAscii = 63 Or KeyAscii = 64 Then
KeyAscii = 0
MsgBox "Invalid input only numbers and letters are allowed", vbInformation, "Invalid Input...Input Again customer number"
Exit Function
End If
If KeyAscii >= 58 And KeyAscii <= 62 Or KeyAscii >= 91 And KeyAscii <= 96 Then
KeyAscii = 0
MsgBox "Invalid input only numbers and letters are allowed", vbInformation, "Invalid Input...Input Again Customer number"
Exit Function
End If
If KeyAscii >= 123 And KeyAscii <= 127 Then
KeyAscii = 0
MsgBox "Invalid input only numbers and letters are allowed ", vbInformation, "Invalid Input...Input Again Customer number"
Exit Function
End If
End Function
Private Sub txtcno_KeyPress(KeyAscii As Integer)
Call txtboxtrap(KeyAscii)
End Sub