' yap, sakto bro...daan pa lagi ko dili ko sure if sakto ba...
' i made some changes. . . hehehe
Private Sub txtItemCode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii=0 ' para dili mu.beep
If txtItemCode.Text = "" Then
MsgBox "Field is empty", vbInformation
Else
If Not CheckIfExists("SELECT fieldName FROM tblName WHERE fieldName='" & txtItem.Text & "'") Then
MsgBox "Item Code does not exists", vbInformation
Else
txtQty.SetFocus
End If
End If
End If
End Sub
Public Function CheckIfExists(strSQL as string) As Boolean
rs.Open strSQL, cn,3,1
If rs.EOF Then
CheckIfExists = False
Else
CheckIfExists = True
End If
rs.close
End Function
'
'
any comments on this:
Private Sub cmdUpdate_Click()
Dim flag As Integer
If txtCustCode.Text = "" Or lblCustName.Caption = "" Or lblCustAddr.Caption = "" _
Or txtDate.Text = "" Or txtPO.Text = "" Or txtPrep.Text = "" Then
MsgBox "Cannot save: Some fields are empty"
ElseIf grdRow.Rows <= 2 Then
MsgBox "Insufficient data", vbCritical
ElseIf checkPO(txtPO.Text) = False Then
MsgBox "PO number not found", vbCritical
ElseIf DoesEmployeeExists(txtPrep.Text) = False Then
MsgBox "Employee ID not found", vbCritical
txtPrep.Text = ""
ElseIf IsDateValid(txtDate) Then
flag = 0
Else
flag = 1
End If
If flag = 0 Then
For i = 1 To Row - 1
query = "Select * from PODFile where PODNo = '" & txtPO.Text & "' AND PODItemCode = '" & grdRow.TextMatrix(i, 1) & "' "
If DoesThisExists(rsPOD, query) Then
With rsPOD
.Edit
!PODPrice = CCur(grdRow.TextMatrix(i, 4))
!PODQty = !PODQty + Val(grdRow.TextMatrix(i, 3))
!PODQtyBal = !PODQtyBal + Val(grdRow.TextMatrix(i, 3))
!PODStat = "OP"
.Update
Else <<<<<<<<<<<<<<<<<<<<<<----- ngnao else without if mani?
.AddNew
!PODNo = txtPO.Text
!PODItemCode = grdRow.TextMatrix(i, 1)
!PODPrice = CCur(grdRow.TextMatrix(i, 4))
!PODQty = Val(grdRow.TextMatrix(i, 3))
!PODQtyBal = Val(grdRow.TextMatrix(i, 3))
!PODStat = "OP"
.Update
End With
End If
Next i
With rsPOH
.Edit
!POHDATE = CDate(txtDate.Text)
!POHCustCode = Trim(txtCustCode.Text)
!POHPrepBy = txtPrep.Text
!POHStat = "OP"
.Update
End With
MsgBox "Pob Order Update Saved Successfully", vbInformation
Call Clear(frmupdate)
Call ClearGrid(grdRow, Row)
End If
End Sub
' bro ang With rsPOD ibutang igbaw sa If DoesThisExists(rsPOD, query) Then
' ug ang End With ibutang in between End If ug Next i
'
'
asa dapit nako ibutang ang ang rs.close, db.closeor set rs = nothing? angay pa jud i.close ang db or rs to nothing?
module
public dbase as database
public rsPOH as recordset
public rsPOD as recordset
Private Sub cmdUpdate_Click()
Dim flag As Integer
If txtCustCode.Text = "" Or lblCustName.Caption = "" Or lblCustAddr.Caption = "" _
Or txtDate.Text = "" Or txtPO.Text = "" Or txtPrep.Text = "" Then
MsgBox "Cannot save: Some fields are empty"
ElseIf grdRow.Rows <= 2 Then
MsgBox "Insufficient data", vbCritical
ElseIf checkPO(txtPO.Text) = False Then
MsgBox "PO number not found", vbCritical
ElseIf DoesEmployeeExists(txtPrep.Text) = False Then
MsgBox "Employee ID not found", vbCritical
txtPrep.Text = ""
ElseIf IsDateValid(txtDate) Then
flag = 0
Else
flag = 1
End If
If flag = 0 Then
For i = 1 To Row - 1
query = "Select * from PODFile where PODNo = '" & txtPO.Text & "' AND PODItemCode = '" & grdRow.TextMatrix(i, 1) & "' "
If DoesThisExists(rsPOD, query) Then
With rsPOD
.Edit
!PODPrice = CCur(grdRow.TextMatrix(i, 4))
!PODQty = !PODQty + Val(grdRow.TextMatrix(i, 3))
!PODQtyBal = !PODQtyBal + Val(grdRow.TextMatrix(i, 3))
!PODStat = "OP"
.Update
Else
.AddNew
!PODNo = txtPO.Text
!PODItemCode = grdRow.TextMatrix(i, 1)
!PODPrice = CCur(grdRow.TextMatrix(i, 4))
!PODQty = Val(grdRow.TextMatrix(i, 3))
!PODQtyBal = Val(grdRow.TextMatrix(i, 3))
!PODStat = "OP"
.Update
End With
End If
Next i
With rsPOH
.Edit
!POHDATE = CDate(txtDate.Text)
!POHCustCode = Trim(txtCustCode.Text)
!POHPrepBy = txtPrep.Text
!POHStat = "OP"
.Update
End With
MsgBox "Pob Order Update Saved Successfully", vbInformation
Call Clear(frmupdate)
Call ClearGrid(grdRow, Row)
End If
End Sub
Last edited by lestat1116; 09-27-2010 at 03:41 PM.
Set rs=nothing ' para nko need ni bro kung human na ka gamit sa rs
Cn.Close ' pwede ra dili i.close, error handler lang bro para i.check ang connection sa kada gamit nim
' kung close ang connection, den i.open ug utro. . .
'
' obserbare lang bro, para ikaw jud ang makasabot kanus-a gamit ug ing.ana...
'
'
paki sawsaw sad gale..
unsa d.i ako sayop ani ai.. nganu ma error man siya if butangan nako og orh.update and rORD.update.. kung wala kay ma save siya pero wala makita sa ako database.. anu comments?
Private Sub cmdsave_Click()
If checkFields = True Then
MsgBox "Cannot save because thier are still empty fields!hell yea!", vbCritical
Else
'save ORheader
orh.AddNew
orh!ORHNum = txtORNo.Text
orh!ORHDate = Format(Date, "mm/dd/yyyy")
orh!ORHCustCode = txtCode.Text
orh!ORHPrepBy = txtpby.Text
orh!ORHGrandTotal = GrandTotal
orh!ORHStatus = "OP"
orh.Update
For k = 1 To (r - 1)
'save ORdetail
rORD.AddNew
rORD!ORDNum = txtORNo.Text
rORD!ORdItemCode = grd.TextMatrix(k, 1)
rORD!ORDQty = grd.TextMatrix(k, 3)
rORD!ORDtotal = Val(grd.TextMatrix(k, 3)) * Val(grd.TextMatrix(k, 4))
rORD!ORDStatus = "OP"
rORD.Update
Next
MsgBox "Customer file successfully save", vbInformation
End If
'Format(total, "#,#0.0")
End Sub
Salamat sa inyo mga help ninyo! Thank you kaayo
Similar Threads |
|