Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2003
    Posts
    52

    Red face Unanswered: how to use DAO thing with select query

    i have been seeing posts in this forum, but i have tried many example of select query with DAO , none works, it gives the error user-defined type not defined. wat to do

  2. #2
    Join Date
    Jan 2003
    Posts
    52

    Thumbs up Re: how to use DAO thing with select query

    i have donw it myself, actually i didn't know how to add the reference

  3. #3
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: how to use DAO thing with select query

    Originally posted by waqas
    i have been seeing posts in this forum, but i have tried many example of select query with DAO , none works, it gives the error user-defined type not defined. wat to do

    Hi:
    just make sure u add this ADO lib in ur references and thats all.

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: how to use DAO thing with select query

    Originally posted by VBAPROGRAMMER
    Hi:
    just make sure u add this ADO lib in ur references and thats all.
    or even the DAO lib,
    heres an example i've used

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("Overdue", dbOpenSnapshot, dbReadOnly)

    and another using a table

    Sub getMail()
    Dim inboxcontense As Outlook.Items, email As MailItem

    Dim rs As DAO.Recordset
    Set inboxcontense = CreateObject("Outlook.Application").GetNamespace(" MAPI").GetDefaultFolder(olFolderInbox).Items
    Set rs = CurrentDb.OpenRecordset("jobs", , dbAppendOnly)
    For Each email In inboxcontense
    With rs
    .AddNew
    !User = email.SenderName
    !DateReported = email.SentOn
    !DescriptionBrief = email.Subject
    !DescriptionFull = email.Body
    !Status = 1
    .Update
    End With
    email.Delete
    Next
    End Sub

    both work fine if you've got the dao lib inclued in the tool-->refferences section though the second also needs the outlook lib
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Jan 2003
    Posts
    52
    actually i want to use a select query with DAO, so plz if u ppl help me with this, and i'll be thankful if u could explain it also, that wats happening in the code. lets take a simple example, like
    SELECT * FROM TABLE1

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    that is what i've done, only i've saved the query seperatly so where mine reads

    Set rs = CurrentDb.OpenRecordset("Overdue", dbOpenSnapshot, dbReadOnly)

    yours should read

    Set rs = CurrentDb.OpenRecordset("SELECT * FROM TABLE1", dbOpenSnapshot, dbReadOnly)
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Re: how to use DAO thing with select query

    Originally posted by waqas
    i have donw it myself, actually i didn't know how to add the reference
    in the vb editor click tools then click refferences then check Microsoft DAO 3.X object library
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  8. #8
    Join Date
    Jan 2003
    Posts
    52

    Re: how to use DAO thing with select query

    Originally posted by m.timoney
    or even the DAO lib,
    heres an example i've used

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("Overdue", dbOpenSnapshot,
    .
    .
    .
    cond also needs the outlook lib

    jus tthis :O, good, but how to display this on screen plus one more thing how to plot a graph through the query, and plz explain the procedure also, i m really getting to somewhere through ur replies

  9. #9
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    While Not rs.EOF
    DoCmd.SendObject , , , rs("firstname") & "." & rs("surname") & "@uk.agimedia.com", , , "job overdue: " & rs("DecriptionBrief"), rs("DescriptionFull"), True, ""
    rs.MoveNext
    Wend

    this chunk of code uses my recordset to make a email list, how to change this depends on what you what to do with it but basicly

    While Not recordsetVar.EOF
    recordsetVar("FieldName")
    ...
    recordsetVar.MoveNext
    wend
    is all you need

    as for the graph i normaly use excel
    Last edited by m.timoney; 01-14-03 at 13:47.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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