Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    9

    Unanswered: change or read a field from a table

    HI

    How can I change or read a field from a table using visual basic, lets say store a number in the first row of a table or read the third value of a table without using SQL;

    it must be something like tablename![field name] . sotmething

    please hlp

    thanks
    Dimitris

  2. #2
    Join Date
    Mar 2002
    Posts
    192
    Using the ADO library.. This example works in MS Access for VB you will have to set up the connection string

    Dim cn as new adodb.connection
    Dim rs as new adodb.recordset

    set cn = CurrentProject.Connection

    rs.open "SELECT * FROM tblTest"
    msgbox rs.Fields(0) ' Show the first record's field 1 value by field position
    rs.moveNext ' I'm assuming you have at least 3 records here
    rs.moveNext ' I'm assuming you have at least 3 records here
    msgbox rs.Fields("MyField") ' Show 3rd record's field 1 value by field name

    rs.close
    cn.close

    set rs = nothing
    set cn = nothing

Posting Permissions

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