0

Ah. Thats our problem right there. I have used the listview from service pack 6 which is way better than the other service pack controls. Download SP6 from here and install. In your components, deselct the other controls and select microsoft windows common controls 6.0 sp6. That should clear your errors and the code will run properly. :)

Also, select the listview and set its dridline property to true, its view property to 3 lvwReport

0

I already have mircosoft windows common contrlos 6.0 sp6, but that is giving problem here rather Microsoft common control 5.0 (SP2) component is giving the solution.

0

Which is why I suggested that you re-install sp6 again. There should be no problems with sp6's controls...

0

still having error : 124
in the follwing line of code

rs.Open ("SELECT * FROM tblstock WHERE code = '" & xcode & "'"), con, adOpenDynamic, adLockOptimistic
0

Where did you gave a value to xcode. Is the value correct. Also try and use this ...

rs.Open ("SELECT * FROM tblstock WHERE code = '" & xcode & "'"), con, adOpenStatic, adLockOptimistic
0

xcode is the value that everything is depending on, all the calculations and database update will be based on xcode. it is the product code lying in the first column of listview1. here is the code I have for xcode

For Each li In ListView1.ListItems
xcode = li.SubItems(1)

I will also try your changes too.

0

Have you checked to see if xcode actually returned a value at all. That might be your problem right there because the database is looking for a value whilst a NULL value was returned...

0

didn't understand what you trying to say ? How can I check that ?

Edited by silversurf

0

Nobody is helping anymore because you are not on a level as yet to write code on this level. You need to study more to understand the code that you are copying and pasting. We give help but you do not understand the core basics of our answers. (I am saying this with all do respect) Study the listview, there is tons of tutorials on line that you can study.

We are already on the 37th post and the answer was given a few times, yet you do not know how to call a value from a variable...

We are helping here spending our own free time to see that you get a solution. Unfortunately we can only bring you to the water, you need to drink out of your own free will.

Once you have your code, BEFORE the error, see if xcode has a value - msgbox xcode.

0

Thank you sir for replying. Yes I know I am in the 37th post of this question but still don't have my question solved, doesn't that mean we are having some particular problem here, I have almost constructed my code (yes I admit I copy paste it) Just asking for help for that particular one line of code, I have done all the calculations, all other things, just asking and mentioning that one little thing almost in each post that "xcode" is the product code or referrence that I am trying to use here as the basis of my all calculation and database update and still I don't have that one line code throug which I can call xcode from the column1 of my listview1, how terrible. you have shown me the vsdebugger, the SP6 and many other way of things around but still can not give me one line of code by which I can pick my "xcode" and you are telling me that you are trying to help ? yes, I am still trying to figure it out as per line by line you are saying by putting all my time and effort as I am a newbie in vb6, but you, those who are claiming them as expert cannot solve one litte line of code and still scolding me for my foolishishness and indicating some thing to a particular animal ?? if you can not solve it just say we can not, we are sorry, I will try something or somewhere elese,

0
heyyyyy...
can i suggest something..??
you wanted to update the quantity of the product if a customer return an item right??
and then subtract your total sales if the item was returned by a customer..
was that it?? ...

hmm..try this
put  labels to display the quantity of the item_number of your product
and the quantity of the item/s to be returned

label1=val(label1)+val(label2)
 Call Connect_DB
            Connector.Execute ("Update Table1 set quantity ='" & Val(label) & "'   where ID = '" & Label000 & "' ") <---ID here is your product item_number when you select it from the listview

 the same with your product sales..but you only have to subtract it..
            just make another label for the sales

   another thing....be sure to set the labels properties to visible=false
  to make it hidden...
0

thanks hyesin for replying. Yea your idea was good but as I am producing the return item from my sales invoice number, thats why I preffered 2 listviews in my form one which will collect the data from the particular invoice number and the other which will collect the item which the customer wants to return form that particular invoice number, what if the customer wants to return more then one product from the same invoice number ??

0

As per andreret suggestion i have the following code now :

Dim xsprice As Integer
    Dim xsprice1 As Integer
    Dim xsquantity As Integer
    Dim xsquantity1 As Integer
    Dim xcode As String
    Dim xprofit As Integer
    Dim xprofit1 As Integer
    Dim xtotalonhand As Integer
    Dim xtotalreturn As String
    Dim xdiscount As String
    Dim xsinvno As String
    Dim xsinvdt As String
    Dim xremark As String
    Dim xreturnprice As String
    Dim li As ListItem
    Dim mylist As Integer
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim rs1 As ADODB.Recordset
With ListView1
For Each li In ListView1.ListItems
xcode = ListView1.ListItems(1)
xtotalreturn = li.SubItems(1)
xreturnprice = li.SubItems(2)
Next li
MsgBox xcode
MsgBox xtotalreturn
MsgBox xreturnprice
Set cn = New ADODB.Connection
        cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\main.mdb;Persist Security Info=False"
        cn.Open
        Set rs = New ADODB.Recordset
        rs.Open ("SELECT * FROM tblstock WHERE code = '" & xcode & "'"), con, adOpenStatic, adLockOptimistic
        xtotalonhand = rs!on_hand
        rs!on_hand = Val(xtotalreturn) + Val(xtotalonhand)
        rs1.Open ("SELECT * FROM tblsales WHERE code = '" & xcode & "'"), con, adOpenDynamic, adLockOptimistic
        xprofit = rs1!Profit
        xsquantity = rs1!squantity
        xsprice = rs1!sprice
        xsquantity1 = Val(xsquantity) - Val(xtotalreturn)
        xprofit1 = (Val(xprofit) / Val(xsquantity)) * (Val(xsquantity1))
        'xprofit1 = (Val(xprofit) / Val(xsquantity)) * (Val(xsquantity) - Val(xtotalreturn))
        xsprice1 = Val(xsprice) - Val(xreturnprice)
        rs1!Profit = xprofit1
        rs1!squantity = xsquantity1
        rs1!sprice = xsprice1
        rs1.Update
        rs.Update
        'End With
        End With

now I am having the value of xcode, xtotalreturn and xreturn price accordingly, but still having the run time error '3001' " Arguments are of the wrong type, are out of range, or are in conflict with one anoteher" in the following line of code :

rs.Open ("SELECT * FROM tblstock WHERE code = '" & xcode & "'"), con, adOpenStatic, adLockOptimistic       

I have searched through google, as long as my perception goes it have something with data type may be. I have xcode as string here and in my access database I have code field as text, I don't know what I am doing wrong here ?

0

Zip your project AND database and post it here. I will have a look and will correct accordingly.

I have done a basic test and my code runs fine. If I can see what versions you are running we can maybe get to the soution.

Well done on the msgbox parts, that was exactly what I was talking about. If a value is returned, we know that the error is afterwards. I need to see your database structure and the code etc.

Edited by AndreRet

0

I will have a look tonight when I get back home. I promise not to laugh. No code is silly, the fact that you have written it is in it self a good start... :)

0

Ok, I'm working on the code now...

Walk me through the steps on whats suppose to happen.
1. User selects a date from dtPicker
2. User selects an invoice number from combo
3. Data shows in Listview 1
4. User double clicks on a row. Row gets added to Listview 2
5. Inputbox pops up to add more stock?
6. User clicks on change button to update stock?
7. Data should now show in datagrid? (which it does not)

Please go through this step by step on how AND what you want to achieve so that I can finish it off.

Edited by AndreRet

0

sorry for the late reply. Yes you are correct about first 4. I am answering from no.5
5. The input box was set there that suppose a user took same product for 2pcs, now the customer wants to keep 1 pcs and want to return anohter pcs, thats why I am giving an oppurtunity to the user to select how many pcs customer wants to return.
6. the thing is, I was putting the code under change button just to try things out and then finaly I want to put the code in the "cmdchange" button which has a caption of confirm change and in the lower left corner under the mshflexgrid. What is the reason is that customer have to take any other product which price will be equivalent or more then the product customer is returning as there will be no option for return money for the return product. When finally the confirm change (cmdchange) button will be clicked, then two things will happen, firstly the return product will added to the stock (on which code you are working now) and the new product will be deducted from the stock.
7. by datagrid did you mean the mshflexgrid ? if so please don't take that in to count to this particular code, that is another part. that is there only for the new product the customer want to purchase in return of the old one.
just make sure the data from the listview 2 (the second listview) should update the database as per the product code.
I think I could make it clear.

0

Cool, I think it makes sense now.

Just to get you past your first part then (and the original question posted here), in your code when you open a recordset, you are using conn as the database connection but you have declared cn. change all the conn's to cn's and the code works fine... Also, you have named the listitems LView (or something similar), in your code you used iview. Change that as well.

I don't have the code in front of me now, just calling from memory. I changed all the namings as above and the code worked perfect...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.