I made a change to a database I inherited and I'm having a problem getting it to work. I thought it was simple? Listed below is the originial code and it works without issue. All I need to do is add a location field (Loc_cls) to the selection. It does not work. Does any one see anything obvious that I am doing wrong? I would greatly appreciate any help.
Originial code = works great…
'Public Sub UpdateQty_TOT(pType As String, pBarcode As String, pQty As Integer)
'Dim mySql As String
'If pType = "I" Then
' mySql = "Update toolcls_Mob set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
' & ") where barcode = '" & pBarcode & "';"
'Else
' mySql = "Update toolcls_Mob set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
' & ") where barcode = '" & pBarcode & "';"
'End If
'DoCmd.RunSQL (mySql)
'End Sub
¬¬¬¬¬¬¬¬¬¬
New Code using Loc _cls field to distinguish different locations:
Public Sub UpdateQty_TOT(pType As String, pBarcode As String, pQty As Integer, pLoc_cls As String)
Dim mySql As String
If pType = "I" And pLoc_cls = "1" Then
mySql = "Update toolcls_Jax set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_Jax set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
Else
If pType = "I" And pLoc_cls = "2" Then
mySql = "Update toolcls_Mob set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_Mob set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
Else
If pType = "I" And pLoc_cls = "3" Then
mySql = "Update toolcls_May set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_May set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
DoCmd.RunSQL (mySql)
End Sub
Originial code = works great…
'Public Sub UpdateQty_TOT(pType As String, pBarcode As String, pQty As Integer)
'Dim mySql As String
'If pType = "I" Then
' mySql = "Update toolcls_Mob set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
' & ") where barcode = '" & pBarcode & "';"
'Else
' mySql = "Update toolcls_Mob set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
' & ") where barcode = '" & pBarcode & "';"
'End If
'DoCmd.RunSQL (mySql)
'End Sub
¬¬¬¬¬¬¬¬¬¬
New Code using Loc _cls field to distinguish different locations:
Public Sub UpdateQty_TOT(pType As String, pBarcode As String, pQty As Integer, pLoc_cls As String)
Dim mySql As String
If pType = "I" And pLoc_cls = "1" Then
mySql = "Update toolcls_Jax set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_Jax set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
Else
If pType = "I" And pLoc_cls = "2" Then
mySql = "Update toolcls_Mob set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_Mob set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
Else
If pType = "I" And pLoc_cls = "3" Then
mySql = "Update toolcls_May set qty_tot = (qty_tot -" & pQty & "), qty_ol = (qty_ol + " & pQty _
& ") where barcode = '" & pBarcode & "';"
Else
mySql = "Update toolcls_May set qty_tot = (qty_tot +" & pQty & "), qty_ol = (qty_ol - " & pQty _
& ") where barcode = '" & pBarcode & "';"
End If
DoCmd.RunSQL (mySql)
End Sub