Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Text Box Equal to Specific Record in List Box

Status
Not open for further replies.

jcmv007

Technical User
Nov 1, 2001
88
US
The subject line might suggest my question is simple but, it's part of a work around I have had to do!

I want a Text Box value to be equal to the first Row and only column of a List Box.

Why I want to do this is because I need to format the value to STANDARD but a List Box does no allow this.

Here is the CODE I've tried which worked fine until I wanted to create a new record. When the form changed to Add Mode my text box TEXT1 is equal to the value of the List Box in the previous record.

Code:
Text39 = Max(Me!List37)
   Dim intCounter As Integer
   Dim bolMoved As Boolean
   Dim strTextBox As String

   bolMoved = False
   For intCounter = 1 To 1
      strTextBox = "Text" & Format(intCounter)
      If Nz(Len(Me.Controls(strTextBox).Value), 0) = 0 Then
         Me.Controls(strTextBox).Value = Me!List37.Value
         bolMoved = True
         Exit For
      End If
   Next intCounter
   If bolMoved = False Then
     Call MsgBox("All the text boxes are full")
   End If

CODE SAMPLE # 2
Code:
If Me.Text1.Visible = False Then
    Me.Text1.Visible = True
    Me.Text1.Value = Me!List37.Value
End If


Any ideas!



James ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top