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

    Unanswered: <You can't reference a property or method for a control unless the control has the fo

    What the ???

    This is just silly. I am trying to do a check on a value in a text box that is partially related to another text box. Here is what I am trying to do... (The problematic line of code has been bolded)


    Code:
    Private Sub txtDescription_Change()
    Dim DescrSQL As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    DescrSQL = "SELECT Users.[Description] FROM Users WHERE Users.[UserName]='" & txtUserName.Text & "';"
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(DescrSQL)
    
    If (rs.RecordCount = 0) Then
    
        'new group description (since it has not been found)
        User_Info_Dirty = True ' set the dirty flag to true (user Description has been updated)
        'Make sure u enable the Add/Update button. (since at least one change has been made!)
        cmdUpdate.Enabled = True
        
    End If
    
    rs.Close
    db.Close
    
    
    End Sub
    Is there a way around this error?

  2. #2
    Join Date
    Sep 2003
    Posts
    30

    Re: <You can't reference a property or method for a control unless the control has the fo

    Originally posted by shassouneh
    What the ???

    This is just silly. I am trying to do a check on a value in a text box that is partially related to another text box. Here is what I am trying to do... (The problematic line of code has been bolded)


    Code:
    Private Sub txtDescription_Change()
    Dim DescrSQL As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    DescrSQL = "SELECT Users.[Description] FROM Users WHERE Users.[UserName]='" & txtUserName.Text & "';"
    
    Set db = CurrentDb()
    Set rs = db.OpenRecordset(DescrSQL)
    
    If (rs.RecordCount = 0) Then
    
        'new group description (since it has not been found)
        User_Info_Dirty = True ' set the dirty flag to true (user Description has been updated)
        'Make sure u enable the Add/Update button. (since at least one change has been made!)
        cmdUpdate.Enabled = True
        
    End If
    
    rs.Close
    db.Close
    
    
    End Sub
    Is there a way around this error?
    Hi, shassouneh!

    I had the same problem awhile back. I believe the solution would be:

    [txtUserName].SetFocus

    hth,

    vbprogwb

  3. #3
    Join Date
    Sep 2003
    Posts
    30

    Re: <You can't reference a property or method for a control unless the control has the fo

    Originally posted by vbprogwb
    Hi, shassouneh!

    I had the same problem awhile back. I believe the solution would be:

    [txtUserName].SetFocus

    hth,

    vbprogwb
    You need to place [txtUserName].SetFocus just before the offending line.

    Sorry!

    vbprogwb

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    if you use myTextBox.value ( == myTextBox 'cos .value is the default)

    ...you don't need to .setfocus

    you can collect .value from a textbox that does not have the focus.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Nov 2003
    Posts
    104
    That did the trick. Thanx :0

Posting Permissions

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