Results 1 to 2 of 2

Thread: database "compile error"

  1. #1

    Thread Starter
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    database "compile error"

    Hi,
    Help me to get the following program working..It is a simple example of a database
    but I get a"Compile error" saying "User-defined type not defined" for the underlined lines below...
    Could you please correct my code?
    thanks...
    VB Code:
    1. Dim [U]rsMyRS As Recordset[/U]
    2. Dim dbMyDB As Database
    3. Private Sub cmdUpdate_Click()
    4. rsMyRS.Edit
    5. rsMyRS!Phone = txtPhone.Text
    6. rsMyRS.Update
    7. End Sub
    8. Private Sub cmdDelete_Click()
    9. rsMyRS.Delete
    10. lstRecords.RemoveItem lstRecords.ListIndex
    11. End Sub
    12. Private Sub cmdNew_Click()
    13. rsMyRS.AddNew
    14. rsMyRS!Name = "A New Person"
    15. lstRecords.AddItem rsMyRS!Name
    16. lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID
    17. rsMyRS!Phone = "Person's Phone Number"
    18. rsMyRS.Update
    19. End Sub
    20. Private Sub Form_Load()
    21. Set dbMyDB = OpenDatabase("C:\MyDatabase.mdb")
    22. Set rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)
    23. If Not rsMyRS.EOF Then rsMyRS.MoveFirst
    24. Do While Not rsMyRS.EOF
    25.     lstRecords.AddItem rsMyRS!Name
    26.     lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID
    27.     rsMyRS.MoveNext
    28. Loop
    29. End Sub
    30. Private Sub lstRecords_Click()
    31. rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex))
    32. txtPhone.Text = rsMyRS!Phone
    33. End Sub

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: database "compile error"

    Include the DAO reference in your program and if it is already included prefix your definitions with the appropiate reference.

    Dim rsMyRS As DAO.Recordset

    You should always do this for there are different ypes of recordsets (as well as other definitions).

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