Kiwi-123
asked on
Userform
Please can you help with the attached
On the userform I want to amend the code so that the spinbutton1 alters the date by +1 (Add/Subtract) in textbox1
Book1.xls
On the userform I want to amend the code so that the spinbutton1 alters the date by +1 (Add/Subtract) in textbox1
Book1.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Fanpages, I just need to tweak at the code so that:-
TextBox2.SetFocus
Is performed after the Spinbutton click. My code works if I press the spin button twice, but not if just once?
Private Sub SpinButton1_SpinUp()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", 1, CDate(TextBox1.Text)))
TextBox2.SetFocus
End If
End Sub
TextBox2.SetFocus
Is performed after the Spinbutton click. My code works if I press the spin button twice, but not if just once?
Private Sub SpinButton1_SpinUp()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", 1, CDate(TextBox1.Text)))
TextBox2.SetFocus
End If
End Sub
Hi,
Try placing a 'DoEvents' call in between the two lines, thus:
Private Sub SpinButton1_SpinUp()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", 1, CDate(TextBox1.Text)))
DoEvents
TextBox2.SetFocus
End If
End Sub
BFN,
fp.
Try placing a 'DoEvents' call in between the two lines, thus:
Private Sub SpinButton1_SpinUp()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", 1, CDate(TextBox1.Text)))
DoEvents
TextBox2.SetFocus
End If
End Sub
BFN,
fp.
Private Sub SpinButton1_SpinUp()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", 1, CDate(TextBox1.Text)))
End If
End Sub
Private Sub SpinButton1_SpinDown()
If IsDate(TextBox1.Text) Then
TextBox1.Text = Format$(DateAdd("d", -1, CDate(TextBox1.Text)))
End If
End Sub
' --- rest of your existing code ---
BFN,
fp.
Open in new window