PDA

Click to See Complete Forum and Search --> : DBGrid query ...


Lil Dave
Jan 28th, 2000, 08:29 AM
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

badal
Jan 28th, 2000, 11:19 AM
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

Lil Dave
Jan 29th, 2000, 09:00 AM
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

LG
Jan 30th, 2000, 11:15 AM
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