Results 1 to 6 of 6
  1. #1
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95

    Auto populate Textbox based on input in other Textbox(es)

    Hello there..

    How to define calculating (or resulting) textbox [text_RESULT], which VB code automatically populates, based on one (or more) inputs in other six textboxes ([text_1,2,3,4,5,6]) (see picture below).

    In input textboxes can be one of two possible inputs (ACC and REJ).

    REJ is stronger than ACC so based on this, please see examples of some of possible situations:

    Click image for larger version. 

Name:	forum1.jpg 
Views:	20 
Size:	150.0 KB 
ID:	30270

    Thank you for helping me here.

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    This will work. This technique allows controls to be referred to as string names constructed in the for-next loop.
    Code:
    Private Sub CalcResult_Click()
    Dim i As Integer
    Dim cName As String
    Dim aForm As String
    
    
    aForm = "MyFormName"
    Text_Result = vbNullString
    For i = 1 To 6
        cName = "Text_" & i
        Select Case Forms(aForm).Controls(cName)
            Case "rej"
                Text_Result = "rej"
                Exit For
            Case "acc"
                Text_Result = "acc"
        End Select
    Next i
    End Sub

  3. #3
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95

    Thumbs up Great and simple solution. Thank you

    I have done it like this and it works!! After populatin textboxes 1 to 6, I refresh the form on F5 and result is there..

    Huge thanks.

    Click image for larger version. 

Name:	Great Solution.jpg 
Views:	15 
Size:	134.2 KB 
ID:	30275

    Quote Originally Posted by davegri View Post
    This will work. This technique allows controls to be referred to as string names constructed in the for-next loop.
    Code:
    Private Sub CalcResult_Click()
    Dim i As Integer
    Dim cName As String
    Dim aForm As String
    
    
    aForm = "MyFormName"
    Text_Result = vbNullString
    For i = 1 To 6
        cName = "Text_" & i
        Select Case Forms(aForm).Controls(cName)
            Case "rej"
                Text_Result = "rej"
                Exit For
            Case "acc"
                Text_Result = "acc"
        End Select
    Next i
    End Sub

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Glad to help. Good luck with the rest of your project!

  5. #5
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Thanks for your help.
    Can you help me here as well?
    Click image for larger version. 

Name:	forum2.jpg 
Views:	13 
Size:	160.5 KB 
ID:	30281

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Sorry, can't correlate concept of Text_1 thru Text_6 into what you are requesting. Doesn't compute for me.
    Perhaps you could adapt my code into a UDF that the query could call to get the results that you want.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 38
    Last Post: 05-03-2017, 09:29 AM
  2. auto populate textbox
    By willfrank in forum Access
    Replies: 1
    Last Post: 04-13-2016, 09:53 AM
  3. Replies: 4
    Last Post: 07-15-2015, 01:39 PM
  4. Auto Populate TextBox
    By Shido151 in forum Access
    Replies: 3
    Last Post: 04-23-2013, 10:41 AM
  5. Input Value based on another textbox value
    By dude19 in forum Access
    Replies: 2
    Last Post: 06-30-2011, 03:48 PM

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
  •  
Other Forums: Microsoft Office Forums