Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Posts
    32

    Talking Unanswered: proramming in access using DAO

    hi
    I am able to connect to database with DAOs.
    But, to place the data on to the textboxes, i need to set focus for the text boxes.

    I am giving the code below

    Private Sub Command5_Click()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = OpenDatabase("C:\Documents and Settings\Administrator\My Documents\db1.mdb")
    Set rs = db.OpenRecordset("student")
    rs.MoveLast
    Text0.SetFocus
    Text0.Text = rs(0)
    Text2.SetFocus
    Text2.Text = rs(1)
    rs.Close
    db.Close
    End Sub

    Why should i need to set focus like that?

    Can anyone help me?

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb Re: proramming in access using DAO

    Originally posted by annam
    hi
    I am able to connect to database with DAOs.
    But, to place the data on to the textboxes, i need to set focus for the text boxes.

    I am giving the code below

    Private Sub Command5_Click()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = OpenDatabase("C:\Documents and Settings\Administrator\My Documents\db1.mdb")
    Set rs = db.OpenRecordset("student")
    rs.MoveLast
    Text0.SetFocus
    Text0.Text = rs(0)
    Text2.SetFocus
    Text2.Text = rs(1)
    rs.Close
    db.Close
    End Sub

    Why should i need to set focus like that?

    Can anyone help me?
    You don't need to set the focus if you use it as follow
    Text0 = rs(0)
    Text2 = rs(1)

    and so on

  3. #3
    Join Date
    Nov 2003
    Posts
    32

    Re: proramming in access using DAO

    Thanks for your reply.

    Can you please tell me why is that so?

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Question Re: proramming in access using DAO

    Originally posted by annam
    Thanks for your reply.

    Can you please tell me why is that so?
    I think perhps because when you use the .text, then you use the property or the methoud of that object, so it should be in Focus.

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    100%

    thing.text requires the focus set to thing

    thing.value does not require focus (and you can omit .value cos it is the default property)

    as far as i recall, .text is the only property requiring focus

    izy
    currently using SS 2008R2

Posting Permissions

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