C
Chris
Hi all,
I am doing a course in VB and have written a small sales program but I
have hit a wall with the following problem.
I made a Dim for ordernumber and I made a ADOdc7 which is linked with
a database and a table in access, but I cant get the Dim to work and
make it save the info in the program to the database table which will
be for billing. Any idea what is wrong with this code?? I have pasted
it following this message so please have a look and anything with
List***.text or txt***.text is a text box or list box.
ADOdc4 has the product information and ADOdc7 is the billing table
which the manager needs to view at the end of the day with all the
sales saved into it. I can't figure out the problem with it yet so all
help will be greatly appreciated.
Also I have uploaded a zipped copy of the program to alt.binaries.test
if anyone needs it to help me with the problem. All that needs to be
done is to rebuild the ADO's to the new location of the database file
to make it run.
Also the Employee login password is "staff" and the manager login
password is "boss" if anyone gets this program.
Best regards,
Chris
Dim OrderNo As Integer
Dim Quantity As Integer
Dim ItemPrice, DeliveryPrice, SpeedPrice, Totalcost, QuantityPrice,
TotalPrice As Currency
Private Sub Form_Load()
With Adodc7.Recordset
.MoveLast
OrderNo = ![OrderNumber]
.MoveFirst
End With
End Sub
Private Sub cmdOrder_Click()
With Adodc7.Recordset
.AddNew 'adds new empty record
'below textbox values are
saved into the fields
![First Name] = TxtFN.Text
![last Name] = TxtLN.Text
![Total Price] = TxtTotal.Text
![Delivery Location] = ListDest.Text
![Product Name] = ListProduct.Text
![Quantity In Stock] = TxtAmt.Text
![Quantity Bought] = ListQuantity.Text
![Restock Number] = TxtRestock.Text
![Date] = TxtDate.Text
![Time] = TxtTime.Text
OrderNo = OrderNo + 1 'gets a new order #
![OrderNumber] = OrderNo
.Update 'Saves all the fields
MsgBox "Transaction saved"
End With
With Adodc4.Recordset ' calculates current stock
.Find "[Product Name] = '" & ListProduct.Text & "'"
![Amt In Stock] = ![Quantity In Stock] - Quantity
.Update
End With
End Sub
I am doing a course in VB and have written a small sales program but I
have hit a wall with the following problem.
I made a Dim for ordernumber and I made a ADOdc7 which is linked with
a database and a table in access, but I cant get the Dim to work and
make it save the info in the program to the database table which will
be for billing. Any idea what is wrong with this code?? I have pasted
it following this message so please have a look and anything with
List***.text or txt***.text is a text box or list box.
ADOdc4 has the product information and ADOdc7 is the billing table
which the manager needs to view at the end of the day with all the
sales saved into it. I can't figure out the problem with it yet so all
help will be greatly appreciated.
Also I have uploaded a zipped copy of the program to alt.binaries.test
if anyone needs it to help me with the problem. All that needs to be
done is to rebuild the ADO's to the new location of the database file
to make it run.
Also the Employee login password is "staff" and the manager login
password is "boss" if anyone gets this program.
Best regards,
Chris
Dim OrderNo As Integer
Dim Quantity As Integer
Dim ItemPrice, DeliveryPrice, SpeedPrice, Totalcost, QuantityPrice,
TotalPrice As Currency
Private Sub Form_Load()
With Adodc7.Recordset
.MoveLast
OrderNo = ![OrderNumber]
.MoveFirst
End With
End Sub
Private Sub cmdOrder_Click()
With Adodc7.Recordset
.AddNew 'adds new empty record
'below textbox values are
saved into the fields
![First Name] = TxtFN.Text
![last Name] = TxtLN.Text
![Total Price] = TxtTotal.Text
![Delivery Location] = ListDest.Text
![Product Name] = ListProduct.Text
![Quantity In Stock] = TxtAmt.Text
![Quantity Bought] = ListQuantity.Text
![Restock Number] = TxtRestock.Text
![Date] = TxtDate.Text
![Time] = TxtTime.Text
OrderNo = OrderNo + 1 'gets a new order #
![OrderNumber] = OrderNo
.Update 'Saves all the fields
MsgBox "Transaction saved"
End With
With Adodc4.Recordset ' calculates current stock
.Find "[Product Name] = '" & ListProduct.Text & "'"
![Amt In Stock] = ![Quantity In Stock] - Quantity
.Update
End With
End Sub