Results 1 to 4 of 4

Thread: DBGrid query ...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Christchurch, New Zealand
    Posts
    19

    Post

    I can't remember if I posted here about how to get a DBGrid to show related fields in another table.

    For example ... all records in the Orders Table have a Status field that can be 1,2,3 etc and they link to a Status Description Table, that has the 1,2,3 etc linking up to short 15 character descriptions.

    Now I can do it in Crystal Reports, but I would like to be able to show it on a DBGrid before printing it ... I think clunietp suggested an SQL join statement ... can you or anyone give me some demo code to work from ?

    As always I appreciate the time.

    Cheers Dave

  2. #2
    New Member
    Join Date
    Jan 2000
    Posts
    4

    Post

    Dim openSQL As String
    Dim mdb As DAO.Recordset
    Dim rst As DAO.Recordset

    'the sql statment joining the 2 or more tables
    openSQL = " SELECT ... "

    Set rst = mdb.OpenRecordset(openSQL)
    Set DBGrid1.Recordset = rst
    DBGrid1.Refresh


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Christchurch, New Zealand
    Posts
    19

    Post

    Hi,

    Thanks for your reply, although I guess I should have specified that I was using VB 5 and Access 97.

    Couldn't find the DBGrid1.Recordset property.

    Any other suggestions out there ?

    Cheers Dave

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi, DBGrid control doesn't have Recordset property. Usually DBGrid is connected to datacontrol and then you use datacontrol properties:

    Dim sqlStr As String
    sqlStr = "select * from categories where categoryID=1 or categoryID=2 "
    Data1.RecordSource = sqlStr
    Data1.Refresh

    Larisa


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