Results 1 to 6 of 6

Thread: Data Problem!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Question Data Problem!

    I keep getting this Error but don't undersand why
    Would someone please help me??
    Code:
    Option Explicit
    Dim db As Database
    Dim rs As Recordset
    Dim lstmain1 As ListItem
    Dim lstmain2 As ListItem
    Dim clmhead1 As ColumnHeader
    Dim clmhead2 As ColumnHeader
    Private Sub Form_Load()
    Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\PatsInventory.mdb")
    Set clmhead1 = lvwSuppliers.ColumnHeaders.Add(, , "Supplier ID", lvwSuppliers.Width)
    SupplierView
    
    
    End Sub
    
    Private Sub cmdEdit_Click()
    cmdCSave.Visible = True
            txtSupplierName.Locked = False
            txtContactName.Locked = False
            txtContactTitle.Locked = False
            txtAddress.Locked = False
            txtCity.Locked = False
            txtState.Locked = False
            txtPostal.Locked = False
            txtCountry.Locked = False
            txtPhone.Locked = False
            txtFax.Locked = False
            txtSupplierName.SetFocus
    End Sub
    
    Private Sub cmdSave_Click()
    Set rs = db.OpenRecordset("Suppliers")
    cmdSave.Visible = False
            txtSupplierName.Locked = True
            txtContactName.Locked = True
            txtContactTitle.Locked = True
            txtAddress.Locked = True
            txtCity.Locked = True
            txtState.Locked = True
            txtPostal.Locked = True
            txtCountry.Locked = True
            txtPhone.Locked = True
            txtFax.Locked = True
            
            While Not rs.EOF
            If lvwSupplier.SelectedItem.Text = rs!ContactID Then
                rs.Edit
                rs!SupplierName = txtSupplierName.Text
                rs!ContactName = txtContactName.Text
                rs!ContactTitle = txtContactTitle.Text
                rs!Address = txtAddress.Text
                rs!City = txtCity.Text
                rs!State = txtState.Text
                rs!Postal = txtPostal.Text
                rs!Country = txtCountry.Text
                rs!Phone = txtPhone.Text
                rs!Fax = txtFax.Text
                rs.Update
                rs.MoveLast
                rs.MoveNext
            Else
                rs.MoveNext
            End If
            Wend
    End Sub
    
    Private Sub cmdAdd_Click()
    frmAddSuppliers.Show vbModal
    End Sub
    
    Private Sub cmdView_Click()
    ContactView
    rs.Close
    End Sub
    Private Sub lvwSuppliers_Click()
    Set rs = db.OpenRecordset("Suppliers")
    While Not rs.EOF
    If lvwSuppliers.SelectedItem.Text = rs!SupplierID Then
        txtSupplierName.Text = rs!SupplierName
        txtContactName.Text = rs!ContactName
        txtContactTitle.Text = rs!ContactTitle
        txtAddress.Text = rs!Address
        txtCity.Text = rs!City
        txtState.Text = rs!State
        txtPostal.Text = rs!Postal
        txtCountry.Text = rs!Country
        txtPhone.Text = rs!Phone
        txtFax.Text = rs!Fax
        rs.MoveLast
        rs.MoveNext
    Else
        rs.MoveNext
    End If
    Wend
    
    End Sub
    Private Sub txtFax_Change()
    Dim dig$, i, digi$, digits$
    If txtFax.Text <> "" Then
        dig$ = Mid(txtFax.Text, Len(txtFax.Text), 1)
        If Asc(dig$) < 46 Or Asc(dig$) > 57 Then
            For i = 1 To Len(txtFax.Text) - 1
                digi$ = Mid(txtFax.Text, i, 1)
                digits$ = digits$ & digi$
            Next i
            txtFax.Text = digits$
            txtFax.SelStart = Len(txtFax.Text)
        End If
    End If
    End Sub
    
    Private Sub txtPhone_Change()
    Dim dig$, i, digi$, digits$
    If txtPhone.Text <> "" Then
        dig$ = Mid(txtPhone.Text, Len(txtPhone.Text), 1)
        If Asc(dig$) < 46 Or Asc(dig$) > 57 Then
            For i = 1 To Len(txtPhone.Text) - 1
                digi$ = Mid(txtPhone.Text, i, 1)
                digits$ = digits$ & digi$
            Next i
            txtPhone.Text = digits$
            txtPhone.SelStart = Len(txtPhone.Text)
        End If
    End If
    End Sub
    
    
    
    Public Sub cmdDelete_Click()
    Set rs = db.OpenRecordset("Suppliers")
            txtSupplierName.Text = ""
            txtContactName.Text = ""
            txtContactTitle.Text = ""
            txtAddress.Text = ""
            txtCity.Text = ""
            txtState.Text = ""
            txtPostal.Text = ""
            txtCountry.Text = ""
            txtPhone.Text = ""
            txtFax.Text = ""
        cmdDelete.Enabled = False
        cmdEdit.Enabled = False
    While Not rs.EOF
        If frmMain.lvwSuppliers.SelectedItem.Text = rs!SupplierID Then
        rs.Delete
        ContactView
            If rs.RecordCount = 0 Then
                Exit Sub
            Else
                rs.MoveLast
            End If
        rs.MoveNext
        Else
        rs.MoveNext
        End If
    Wend
    rs.Close
    End Sub
    Public Sub SupplierView() '<<<<<<<<-------------- Iam getting my Error here Somone please Help Thanks!!
    Set rs = db.OpenRecordset("Suppliers")
    frmSuppliers.lvwSuppliers.ListItems.Clear
        While Not rs.EOF
        Set lstmain1 = frmSuppliers.lvwSuppliers.ListItems.Add(, , rs!SupplierID)
        rs.MoveNext
        Wend
        If rs.RecordCount = 0 Then
            MsgBox "There are no records on the database"
        Else
            frmSuppliers.lvwSuppliers.Enabled = True
            frmSuppliers.cmdCDelete.Enabled = True
            frmSuppliers.cmdCEdit.Enabled = True
        End If
    End Sub

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Can you be more specific as to the line the error occurs on, because i don't thing you can get an error on the actual procedure declaration line (s you've indicated).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    Addicted Member
    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    245

    Lightbulb May i comment

    May be this helps...
    U should Select at lease 1 field to loop thru new open recordset
    VB Code:
    1. Public Sub SupplierView()
    2. Set rs = db.OpenRecordset("SELECT SupplierID FROM Suppliers")
    3. If rs.RecordCount <=0 then Goto NoRecord
    4. rs.MoveFirst
    5. frmSuppliers.lvwSuppliers.ListItems.Clear
    6.     While Not rs.EOF
    7.     Set lstmain1 = frmSuppliers.lvwSuppliers.ListItems.Add(, , rs!SupplierID)
    8.     rs.MoveNext
    9.     Wend
    10.     frmSuppliers.lvwSuppliers.Enabled = True
    11.     frmSuppliers.cmdCDelete.Enabled = True
    12.     frmSuppliers.cmdCEdit.Enabled = True
    13. Exit Sub
    14.  
    15. NoRecord:
    16.         MsgBox "There are no records on the database"
    17.     Exit Sub
    18. End Sub
    I may have interpret your post wrongly
    Correct me if I made a mistake...
    Hope This Helps.. .....Enjoy Coding.....//


    zak2zak

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183
    I ended up changing the whole thing but I still don't see what I did wrong.
    I have been reading in my book but it talks more about SQL than Access
    I will post the Util maybe someone will look at it and tell me what I’m doing wrong.
    Thanks a lot for the reply !!!!!
    Last edited by Rally; Sep 7th, 2003 at 02:02 PM.

  5. #5
    Addicted Member
    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    245

    Lightbulb May i comment

    May be this helps...
    I have checked u'r code and u'r database
    The Database is empty?
    U need to have records in the database to view it in the list...
    I may have interpret your post wrongly
    Correct me if I made a mistake...
    Hope This Helps.. .....Enjoy Coding.....//


    zak2zak

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183
    Even if I go ahead and populate it, there are errors that I don’t understand
    However, thanks for the reply!

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