Need help using datagrid

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JingleBEV

    #1

    Need help using datagrid

    Hi all,

    I don't seem to get this going, possibly lacking the knowledge of dao
    recordset. I try to fill this Datagrid with the DAO.recordset, but it keeps
    giving me the error 13 - datatype mismatch. Can somesone shed some light
    please.

    I define
    rsDepartmentLis t as Dao.recordset

    and I use Datagrid1 in the form

    Here's the sample code:
    ....
    Set DataGrid1.DataS ource = rsDepartmentLis t
    ....
    Is there anyway I can cast the recordset datatype to make it compatible with
    that of the datagrid.dataso urce? Please give the sample code if it's
    possible.

    Your help is appreciated
    Jing.


  • Albert D. Kallal

    #2
    Re: Need help using datagrid

    I believe the datagrid control requires a ado recordset (not sure what
    version of ms-access and grid control you are using).

    So, to use ado, in place of dao, you can go:

    'An example DAO vs ADO recordset loop, you'll see how similar they are:

    '--- begin DAO ---
    Dim rst As dao.Recordset

    Set rst = CurrentDb.OpenR ecordset("selec t * from contacts")
    Do While rst.EOF = False
    Debug.Print rst!FirstName
    rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing
    '--- end DAO ---

    '--- begin ADO ---
    Dim rs As New ADODB.Recordset

    rst.Open ("select * from contacts"), CurrentProject. Connection
    Do While rst.EOF = False
    Debug.Print rst!FirstName
    rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing

    Anyway, I would try using a ado record set.

    Also, by they way, are you SURE you *really* need a grid control? Check out
    the following screen shots in ms-access using the built in controls, and you
    will see that you have a LOT of ability to build and display grids on the
    screen..but you can use the built in features of ms-access, and it is a
    zillion times easier.




    --
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada
    pleaseNOOSpamKa llal@msn.com



    "JingleBEV" <n_quan@NOSPAMy ahoo.com> wrote in message
    news:JCEKc.1242 $Vw3.263801@new s20.bellglobal. com...[color=blue]
    > Hi all,
    >
    > I don't seem to get this going, possibly lacking the knowledge of dao
    > recordset. I try to fill this Datagrid with the DAO.recordset, but it[/color]
    keeps[color=blue]
    > giving me the error 13 - datatype mismatch. Can somesone shed some light
    > please.
    >
    > I define
    > rsDepartmentLis t as Dao.recordset
    >
    > and I use Datagrid1 in the form
    >
    > Here's the sample code:
    > ...
    > Set DataGrid1.DataS ource = rsDepartmentLis t
    > ...
    > Is there anyway I can cast the recordset datatype to make it compatible[/color]
    with[color=blue]
    > that of the datagrid.dataso urce? Please give the sample code if it's
    > possible.
    >
    > Your help is appreciated
    > Jing.
    >
    >[/color]


    Comment

    Working...