Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Userform coding problem

I have a userform in which two values are input. What I want to do is on exit
from the second text control (txtPurAmt) is clear the current data, set the
focus in the date field and be ready to input another record. What is
happening is that after I set the focus on the txt Date control, the code
wants to run again. Here is what I have so far and have commented where the
problem occurs. Any help is greatly appreciated. Thank you.

Private Sub txtPurAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strAgain As String, bYes As Boolean


Range("A9").End(xlDown).Select
ActiveCell.Offset(1, 0).Select

ActiveCell.Value = Me.txtDate.Value
ActiveCell.Offset(0, 1).Range("A1").Select

ActiveCell.Value = CCur(Me.txtPurAmt.Text)

strAgain = InputBox("Add another record?", "Add New Record?", "Yes")
If strAgain = "Yes" Then
ActiveCell.Offset(1, -1).Select
Me.txtDate.Value = ""
Me.txtPurAmt.Value = ""
bYes = True
Else
Me.txtDate.Value = ""
Me.txtPurAmt.Value = ""
bYes = False
End If

If bYes = True Then
'************
'After the next line, the code starts all over again and the
'Exit Sub line never executes.
Me.txtDate.SetFocus
Exit Sub
Else
UserForm1.Hide
Exit Sub
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Userform coding problem

Not sure I understand. When I run it, and say Yes to the question, it goes
to the date textbox and awaits input.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Billy B" wrote in message
...
I have a userform in which two values are input. What I want to do is on
exit
from the second text control (txtPurAmt) is clear the current data, set
the
focus in the date field and be ready to input another record. What is
happening is that after I set the focus on the txt Date control, the code
wants to run again. Here is what I have so far and have commented where
the
problem occurs. Any help is greatly appreciated. Thank you.

Private Sub txtPurAmt_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strAgain As String, bYes As Boolean


Range("A9").End(xlDown).Select
ActiveCell.Offset(1, 0).Select

ActiveCell.Value = Me.txtDate.Value
ActiveCell.Offset(0, 1).Range("A1").Select

ActiveCell.Value = CCur(Me.txtPurAmt.Text)

strAgain = InputBox("Add another record?", "Add New Record?", "Yes")
If strAgain = "Yes" Then
ActiveCell.Offset(1, -1).Select
Me.txtDate.Value = ""
Me.txtPurAmt.Value = ""
bYes = True
Else
Me.txtDate.Value = ""
Me.txtPurAmt.Value = ""
bYes = False
End If

If bYes = True Then
'************
'After the next line, the code starts all over again and the
'Exit Sub line never executes.
Me.txtDate.SetFocus
Exit Sub
Else
UserForm1.Hide
Exit Sub
End If

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my coding problem? Dan the Man[_2_] Excel Worksheet Functions 3 September 11th 07 12:02 AM
Coding questions about UserForm TextBox excelnut1954 Excel Programming 7 January 13th 06 03:02 PM
Coding problem John[_105_] Excel Programming 3 June 22nd 05 05:39 PM
Help with vba coding/userform.... marty6[_7_] Excel Programming 5 April 27th 04 05:35 PM
Help coding userform Bob Kilmer Excel Programming 0 July 11th 03 01:23 AM


All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"