Results 1 to 40 of 97

Thread: code error 09 in vb 6 accounting system

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2013
    Posts
    64

    Re: code error 09 in vb 6 accounting system

    Public Sub HapKategorin()
    Dim itm As ListItem
    ListView1.ListItems.Clear
    If Not rsKategoria.RecordCount < 1 Then rsKategoria.MoveFirst
    Do Until rsKategoria.EOF
    If Not IsNull(rsKategoria!kat_id) Then Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
    If Not IsNull(rsKategoria!kategoria) Then itm.SubItems(1) = rsKategoria!kategoria
    Here >>>> Label5.Caption = rsKategoria!kategoria <<<<< Here
    rsKategoria.MoveNext
    DoEvents
    Loop
    End Sub


    error runtime 94
    invalid use of null

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: code error 09 in vb 6 accounting system

    To get rid of the 'Invalid use of Null' you could change the code to something like:
    Code:
    Dim itm As ListItem
    ListView1.ListItems.Clear
    If Not (rsKategora.EOF And rsKategoria.BOF) Then
        Do Until rsKategoria.EOF
            If Not IsNull(rsKategoria!kat_id) Then
                Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
                If Not IsNull(rsKategoria!kategoria) Then
                    itm.SubItems(1) = rsKategoria!kategoria
                    Label5.Caption = rsKategoria!kategoria
                End If
            End If
            rsKategoria.MoveNext
        Loop
    End If
    End Sub
    To change all the Prices is quite straightforward. Just put a 'Change Price' Button on the Form and a TextBox (txtDeltaPrice)
    Code:
    Private Sub cmdChangePrice_Click()
    Dim strSQL As String
    Dim curDelta As Currency
    Dim rs As ADODB.Recordset
    If txtDeltaPrice.Text <> "" Then
        If IsNumeric(txtDeltaPrice.Text) Then
            curDelta = CCur(txtDeltaPrice.Text)
            Set rs = New ADODB.Recordset
            strSQL = "SELECT Price FROM Table"
            rs.Open db, adOpenStatic, adLockOptimistic
            If Not (rs.BOF And rs.EOF) Then
                Do Until rs.EOF
                    rs![Price] = rs![Price] + (curDelta * rs![Price] / 100)
                    rs.Update
                    rs.MoveNext
                Loop
            End If
        Else
            MsgBox "Please enter a numeric percentage value to apply to all the Prices"
        End If
    Else
        MsgBox "Change Percentage cannot be blank"
    End If
    End Sub
    where: 'Table' is the name of the table containing the Price, 'Price' is the column name representing the Price and 'db' is an open connection to the DataBase. Assumes that 'Price' is a Currency Type in the Table.

    Entering 2.0 in txtDeltaPrice and clicking the button will uplift all the prices by 2%. Entering -2.0 in txtDelatPrice and clicking the button will reduce all the prices by 2%
    Last edited by Doogle; Jun 20th, 2013 at 01:30 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2013
    Posts
    64

    Re: code error 09 in vb 6 accounting system

    Sir the first code is awesome
    Dim itm As ListItem
    ListView1.ListItems.Clear
    If Not (rsKategoria.EOF And rsKategoria.BOF) Then
    Do Until rsKategoria.EOF
    If Not IsNull(rsKategoria!kat_id) Then
    Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
    If Not IsNull(rsKategoria!kategoria) Then
    itm.SubItems(1) = rsKategoria!kategoria
    Label5.Caption = rsKategoria!kategoria
    End If
    End If
    rsKategoria.MoveNext
    Loop
    End If
    End Sub
    but the second one is not what i want as i already have a Percentage "%" code .. but i want for example
    today 1 Dollar = 5 Euro my products: coca cola 5 Euro
    tomorrow 1 Dollar = 10 Euro my products: coca cola 10 Euro

    now i have the % code but the one i want to change the Dollar to Euro , and by that all prices will rise or get lower prices

    for example : hit here to change currency $ to € , and when i hit it a window appear and i just enter the currency i want then it will automatically calculate all the percentage it self and changes the prices.

    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width