|
-
Feb 24th, 2008, 11:42 PM
#1
Thread Starter
New Member
grid updates but deletes previous content
Hi everyone...
I'm working on a cashier-like program and everytime I purchase a product, an scGrid on the form shows the product that I purchase. the problem is that the scGrid should have a product on it before it can show a product and when it shows the new product that I purchase, it overwrites the previous product that i chose.
Im using this code to update the scGrid:
scGrid.refresh
and when I disable this command, it will not update the scGrid eventhough how many times i addd the product.
please help! need it badly!
-
Feb 25th, 2008, 01:57 AM
#2
Re: grid updates but deletes previous content
you need to show more of your code, writing to the grid, if you want someone to help
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 25th, 2008, 02:00 AM
#3
Re: grid updates but deletes previous content
I don't know what an scGrid is but if its anything like a mshflexigrid be sure you are adding it to rows that do not contain data
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 25th, 2008, 02:05 AM
#4
Thread Starter
New Member
Re: grid updates but deletes previous content
Here's the code, thanks!
Code:
Private Sub PurchaseNA()
Dim purchaseItemTotalCos As String
Dim GetTotalSalar As String
Dim GetTDeduc As String
Dim GetAllPurchaseAmou As String
Dim GetAllowanc As String
Dim Alldeduction As String
purchaseItemTotalCos = purchaseItemTotalCost
GetTotalSalar = GetTotalSalary
GetTDeduc = GetTDeduct
GetAllPurchaseAmou = GetAllPurchaseAmout
GetAllowanc = GetAllowance
If Val(purchaseItemTotalCos) > Val(GetAllowanc) Or Val(purchaseItemTotalCos) = Val(GetAllowanc) Then
Totalme = Val(GetTotalSalar) + 20
Call AddNatinSalary(Totalme - Val(purchaseItemTotalCos))
Call bawansanAllowance("0")
ElseIf Val(purchaseItemTotalCos) < Val(GetAllowanc) Then
Call bawansanAllowance(CStr(Val(GetAllowanc) - Val(purchaseItemTotalCos)))
End If
hold = "0"
rst.Update
SCGrid1.Refresh
Last edited by kamote; Feb 25th, 2008 at 02:50 AM.
-
Feb 25th, 2008, 02:21 AM
#5
Re: grid updates but deletes previous content
rst.Update
SCGrid1.Refresh
you are updating the recordset and then refreshing the grid, but you do not show any code for writing to the recordset.
how many records in your recordset, are you adding new records?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 25th, 2008, 02:49 AM
#6
Thread Starter
New Member
Re: grid updates but deletes previous content
Here it is:
Code:
Private Sub Command3_Click()
Dim totalsAlary1 As String
If Text4.Text = "" Then
MsgBox ("please choose quantity")
Else
Call SetRecordset("Select * From deductToSalary Where codenumber='" & getcodenumber & "'")
totalsAlary1 = CStr(Val(rst.Fields!salary) + Val(rst.Fields!Allowance))
Call SetRecordset("Select * From Product Where itemcode='" & Trim(Text1.Text) & "'")
rst.Fields!Qtty = Val(rst.Fields!Qtty) - Val(Text4.Text)
rst.Update
If Text4.Text = "" Then Exit Sub
Call SetRecordset("Select * From tmpPurchase")
rst.AddNew
rst.Fields!Product = List1.List(List1.ListIndex)
rst.Fields!Itemcode = Text1.Text
rst.Fields!TotalItem = Text4.Text
rst.Fields!totalAmount = Val(Text4.Text) * Val(Text7.Text)
rst.Update
hold = Val(hold) + Val(hold2)
Text6.Text = hold
Command3.Enabled = False
MsgBox ("item added")
Text4.Text = ""
DoEvents
Call PurchaseNA
Call calculate1
------------------------------------------------------------------------
Public Sub calculate1()
DoEvents
Set cnn1 = New ADODB.Connection
cnn1.CursorLocation = adUseClient
cnn1.Open MainConnection
cnn1.BeginTrans
cnn1.Execute "DELETE FROM tmpPurchase"
cnn1.CommitTrans
cnn1.Close
Set cnn1 = Nothing
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|