Dear members
I have a userform with a listbox and several textboxes.The user selects an order no from the listbox and the textboxes are populated with details from that order. The user then manualy fills in some other textboxes and clicks a button whereupon all the details are fed onto the next vacant row of a worksheet. All the textboxes are then returned to a null and the userform becomes available to record the next order. Or at least thats what is meant to happen, and indeed did happen whilst I was working in the VBA environment.
When I went live however the first record was dealt with properly but the text boxes did not populate, for subsequent entries. Here is the basic code I am using.
I have cut out a lot of the code detail so I hope it still makes sense.![]()
Private Sub UserForm_Activate() UserForm1.TextBox12.Value = Format(Now, "dd/mm/yyyy") End Sub Private Sub ListBox1_AfterUpdate() ' To populate Textboxes and to record values 'manualy entered Dim OrdersAr() Sheets("AllLabels").Select Range("C4").Select n = Range("Labels").Rows.Count ReDim OrdersAr(n, 10) OrdersAr = Range("Labels") Sheets("AllLabels").Select OrderNo = UserForm1.ListBox1.Value With UserForm1 For A = 1 To n If OrderNo = OrdersAr(A, 2) Then .TextBox1.Value = OrdersAr(A, 1) .TextBox3.Value = OrdersAr(A, 10) Sheets("DownLoad").Range("Y36").Value = OrdersAr(A, 10) .TextBox9.Value = OrdersAr(A, 4) 'Etc etc .TextBox4.Value = OrdersAr(A, 9) .TextBox13.Value = Sheets("DownLoad").Range("Y31").Value End If Next A End With End Sub a Private Sub CommandButton1_Click() ' The Enter Record Button a EnterRecord a End Sub Sub EnterRecord() 'puts all data into worksheet Dim D As Date Dim Cols1 As Integer Dim Cols2 As Integer Sheets("ENTEREDOs").Activate Range("B4").Select y = ActiveCell.CurrentRegion.Rows.Count Range("B4").Offset(y, 0).Select With UserForm1 D = .TextBox12.Value D = Format(CDate(D), "dd/mm/yyyy") Range("B4").Offset(y, 0).Value = D Range("B4").Offset(y, 1).Value = .TextBox1.Value .ListBox1.BoundColumn = 1 Range("B4").Offset(y, 2).Value = .ListBox1.Value 'OrderNo .ListBox1.BoundColumn = 2 Range("B4").Offset(y, 3).Value = .ListBox1.Value 'JobName Range("B4").Offset(y, 10).Value = .TextBox6.Value ' manualy entered Range("B4").Offset(y, 11).Value = .ListBox3.Value Range("B4").Offset(y, 12).Value = .TextBox4.Value Range("B4").Offset(y, 13).Value = .TextBox7.Value 'manualy entered etc etc End If End With With UserForm1 ' Empties all textboxes etc for next use .TextBox9.Value = "" .ListBox2.Value = "" etc etc ..OptionButton3.Value = False .TextBox5.Visible = True .TextBox15.Visible = True End With End Sub
I suspect that the problem lies with the Sub I have marked "a" but I dont know how to get round it.
Can some body please point me in the right direction
John











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks