Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2014
    Posts
    2

    Unanswered: update unbound text boxes

    I have a form with 3 unbound boxes: "project name" "project number" and "company name" I have a subform that updates when data is entered (or picked from a list) into any of the boxes, that way you can find data by knowing any of the 3 criteria. The subform updates properly but I can't figure out how to update the boxes if one is updated, i.e., if I enter the project number it would be nice if the project name and company name would also update. Any help would be appreciated.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You could use:
    Code:
    Me.Text_ProjectName.Value = DLookUp("ProjectName", "TableName", "ProjectNumber=" & Me.ProjectNumber.Value)
    Me.Text_CompanyName.Value = DLookUp("CompanyName", "TableName", "ProjectNumber=" & Me.ProjectNumber.Value)
    Note: Replace the names used here with the actual names in your project. If ProjectNumber is not numeric, use:
    Code:
    DLookUp("CompanyName", "TableName", "ProjectNumber='" & Me.ProjectNumber.Value & "'")
    Have a nice day!

  3. #3
    Join Date
    Apr 2014
    Posts
    2
    Thank you. I believe this locks my project name and company name into the value of the project number. I would prefer to be able to look up the data by any of the 3 boxes, project name, number or company name. Or am I not putting in the code correctly?

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can create the same procedures for the three textbox controls:
    Code:
    Private Sub ProjectNumber_AfterUpdate()
    
        Me.ProjectName.Value = DLookUp("ProjectName", "TableName", "ProjectNumber=" & Me.ProjectNumber.Value)
        Me.CompanyName.Value = DLookUp("CompanyName", "TableName", "ProjectNumber=" & Me.ProjectNumber.Value)
    
    End Sub
    
    Private Sub ProjectName_AfterUpdate()
    
        Me.ProjectNumber.Value = DLookUp("ProjectNumber", "TableName", "ProjectName='" & Me.ProjectName.Value & "'")
        Me.CompanyName.Value = DLookUp("CompanyName", "TableName", "ProjectName='" & Me.ProjectName.Value & "'")
    
    End Sub
    
    Private Sub CompanyName_AfterUpdate()
    
        Me.ProjectNumber.Value = DLookUp("ProjectNumber", "TableName", "CompanyName='" & Me.CompanyName.Value & "'")
        Me.ProjectName.Value = DLookUp("ProjectName", "TableName", "CompanyName='" & Me.CompanyName.Value & "'")
    
    End Sub
    Have a nice day!

Tags for this Thread

Posting Permissions

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