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.
3 1197
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.
sSQL1 not required. You are going to use just one or the other sql string and set sSQL to that value. -
Private Sub Enter_Click()
-
On Error GoTo Err_Enter_Click
-
Dim dbLocation
-
Dim sSQL
-
dbLocation = "\\Cpfpidc01\FINISHED GOODS\Inventory.mdb"
-
Set objADO = CreateObject("ADODB.Connection")
-
objADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbLocation
-
-
-
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] & "'"
-
-
ELSE
-
-
sSQL = "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] & "'"
-
-
End if
-
-
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
-
Try that
Sorry boss but this is not correct.
But Finaly I got my answer.
problem was in this following line
If((Forms!ShippingEntry!ShippedQuantity) = (PRODUCTION.TTlQuantity)) Then
but I finaly solve it and its like this
Private Sub Enter_Click()
On Error GoTo Err_Enter_Click
Dim dbLocation
Dim sSQL
Dim sSQL1
dbLocation = "\\CPFPIDC01\Users\APatel\Inventory.mdb"
Set objADO = CreateObject("ADODB.Connection")
objADO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbLocation
If (Nz([Forms]![ShippingEntry]![ShippedQuantity], 0) < (DLookup("val(TTlQuantity)", "PRODUCTION", "PalletNo = '" & [Forms]![ShippingEntry]![PalletNo_Combo] & "'"))) Then
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)
Else
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)
End If
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
By the way thanks for ur reply
One problem with the orriginal version of the if statements was the java syntax curly braces at lines 2, 6, 8, 12
and no end if
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bruce Davis |
last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded
tkinter gui application. The problem appears to be a deadlock condition
when a child thread pops up a
Pmw dialog window in...
|
by: Joel |
last post by:
As my registry start condition was working fine, now it's not working anymore
Here are the kind of parameter I use in VSNEt2003:
A) Registry :
Name : Pipo;
Property : PROP1;
RegKey...
|
by: ???? |
last post by:
this is an excerpt from C++ Primer 3rd edition by Lippman, Lajoie.
How might we read an unknown number of input values? At the end of
Section 1.2, we did just that. The
code sequence
string...
|
by: signaturefactory |
last post by:
I am trying the following query in and oleDbCommand:
SELECT PartLocations.LocationName, Sum(PartsJournal.Quantity) AS
SumOfQuantity, PartsJournal.PartsLotNumber
FROM PartLocations INNER JOIN...
|
by: phantom |
last post by:
Hi All.
I am having a problem writing to a file. I can successfully open the
file and write the contents using fprintf, however if the writing is
not done for a while in the process the file...
|
by: Sam Kong |
last post by:
Hello!
Recently I had a strange problem with Visual C# 2005 beta 1.
When I ran(F5 key) a program, <#if DEBUG> statement was not working.
It ran as RELEASE mode.
So I had to manually define...
|
by: Tony |
last post by:
I have an operator== overload that compares two items and returns a new
class as the result of the comparison (instead of the normal bool)
I then get an ambiguous operater compile error when I...
|
by: Kalpana |
last post by:
Hi,
As iam working on convertion of C#1.1 to 2.0. Iam facing a problem
(screen is flickered) while opening and closing any artifacts. When i
tried to debug it is througing ContextSwitchDeadlock...
|
by: abhishekkarnik |
last post by:
Hi,
I am trying to read an exe file and print it out character by
character in hexadecimal format. The file goes something like this in
hexadecimal
0x4d 0x5a 0x90 0x00 0x03 .... so on
When I...
|
by: jesmi |
last post by:
hi all
i have a problem with my code.following is my code:
Connection con = null;
PreparedStatement stmt = null;
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |