Problem with IF condition

B

billy_pit

Hi,
My project is in MS Access 2002.Its on Inventory
In which I have one form, which I used for Shipping Data entry.

I am using this code


Private Sub Enter_Click()
On Error GoTo Err_Enter_Click
Dim dbLocation
Dim sSQL
Dim sSQL1
dbLocation = "\\Cpfpidc01\FINISHED GOODS\Inventory.mdb"
Set objADO = CreateObject("ADODB.Connection")
objADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbLocation

sSQL = "UPDATE PRODUCTION SET SHIPPEDDATE = '" & [Forms]!
[ShippingEntry]![SHIPPEDDATE] & "',ShippedQuantity = '" & [Forms]!
[ShippingEntry]![ShippedQuantity] & "',QTYONHAND =
((PRODUCTION.QTYONHAND)-('" & [Forms]![ShippingEntry]!
[ShippedQuantity] & "')),PackgingSlipNo = '" & [Forms]![ShippingEntry]!
[PackgingSlipNo] & "',Location = '" & [Forms]![ShippingEntry]!
[Location_Combo] & "',Notes = '" & [Forms]![ShippingEntry]![Notes] &
"',Status = '" & [Forms]![ShippingEntry]![Location_Combo] & "' WHERE
PalletNo='" & [Forms]![ShippingEntry]![PalletNo_Combo] & "'"

objADO.Execute (sSQL)
MsgBox "All The Details saved Successfully."
objADO.Close
Set objADO = Nothing
Exit_Enter_Click:
Exit Sub
Err_Enter_Click:
MsgBox Err.Description
Resume Exit_Enter_Click
End Sub




Now in this code I want to put like this



If((Forms!ShippingEntry!ShippedQuantity) = (PRODUCTION.TTlQuantity))
Then
{
sSQL = "UPDATE PRODUCTION SET SHIPPEDDATE = '" & [Forms]!
[ShippingEntry]![SHIPPEDDATE] & "',ShippedQuantity = '" & [Forms]!
[ShippingEntry]![ShippedQuantity] & "',QTYONHAND =
((PRODUCTION.QTYONHAND)-('" & [Forms]![ShippingEntry]!
[ShippedQuantity] & "')),PackgingSlipNo = '" & [Forms]![ShippingEntry]!
[PackgingSlipNo] & "',Location = '" & [Forms]![ShippingEntry]!
[Location_Combo] & "',Notes = '" & [Forms]![ShippingEntry]![Notes] &
"',Status = '" & [Forms]![ShippingEntry]![Location_Combo] & "' WHERE
PalletNo='" & [Forms]![ShippingEntry]![PalletNo_Combo] & "'"

objADO.Execute (sSQL)
}
else
{
sSQL1 = "UPDATE PRODUCTION SET SHIPPEDDATE = '" & [Forms]!
[ShippingEntry]![SHIPPEDDATE] & "',ShippedQuantity = '" & [Forms]!
[ShippingEntry]![ShippedQuantity] & "',QTYONHAND =
((PRODUCTION.QTYONHAND)-('" & [Forms]![ShippingEntry]!
[ShippedQuantity] & "')),PackgingSlipNo = '" & [Forms]![ShippingEntry]!
[PackgingSlipNo] & "'',Notes = '" & [Forms]![ShippingEntry]![Notes] &
"',Status = 'TOBESHIPPED' WHERE PalletNo='" & [Forms]![ShippingEntry]!
[PalletNo_Combo] & "'"

objADO.Execute (sSQL1)
}


But when i did that it shows error that

Object Require

What to do?
I think when I used Condition in IF, it require some recordset, which
I not used in my code.
So please help me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top