sparky251977
New Member
- Joined
- Jul 30, 2010
- Messages
- 3
Hi all i have this code, i need it to do what it does which is open a user form with a text box, set the focus on the text box, print when a user clicks the button and then set the focus back to the textbox for another entry.
The problem.. after it performs the print it does not set the focus back to the text box, code as follows...
Private Sub CommandButton1_Click()
ActiveSheet.Cells(31, 4).Value = Str$(Now)
ActiveSheet.Cells(31, 3).Value = TextBox1
Rows("30:30").Select
Selection.Insert Shift:=xlDown
ActiveSheet.Cells(2, 12).Value = TextBox1
ActiveSheet.PageSetup.PrintArea = "$J$5:$N$19"
ActiveSheet.PrintOut Copies:=1, Collate:=True
FileNum = FreeFile
Open "S:\Downloads\EDI&Prod'n\AssyTracking\WIPLog.txt" For Append As #FileNum
Print #FileNum, TextBox1 & "," & Str$(Now)
Close #FileNum
TextBox1 = ""
End Sub
Private Sub UserForm_Initialize()
With TextBox1
.SetFocus
End With
End Sub
Any suggestions greatly appreciated!
Thanks
Andy
The problem.. after it performs the print it does not set the focus back to the text box, code as follows...
Private Sub CommandButton1_Click()
ActiveSheet.Cells(31, 4).Value = Str$(Now)
ActiveSheet.Cells(31, 3).Value = TextBox1
Rows("30:30").Select
Selection.Insert Shift:=xlDown
ActiveSheet.Cells(2, 12).Value = TextBox1
ActiveSheet.PageSetup.PrintArea = "$J$5:$N$19"
ActiveSheet.PrintOut Copies:=1, Collate:=True
FileNum = FreeFile
Open "S:\Downloads\EDI&Prod'n\AssyTracking\WIPLog.txt" For Append As #FileNum
Print #FileNum, TextBox1 & "," & Str$(Now)
Close #FileNum
TextBox1 = ""
End Sub
Private Sub UserForm_Initialize()
With TextBox1
.SetFocus
End With
End Sub
Any suggestions greatly appreciated!
Thanks
Andy