Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Having to click a Cmd button twice to get it to respond

The 1st sub below performs a Find, then opens up UserForm13. The next 2
subs below it work via command buttons in UserForm13 to show the Next &
Previous records, if there are more than one found in the initial Find.


If I hit the Next button after getting to the last record, I get the
messagebox telling the user that there are no more records found, which
you can see in the sub. After I get that messagebox and click OK, if I
click the Previous button to go backwards, I have to click the Previous
button twice before it starts going back one record for each click.

If I don't click Next far enough to get the messagebox, then the
Previous button will respond Ok with one click. Only if I get to the
point where the messagebox appears.

Can anyone see where I can adjust the code so that it will go back on
the 1st click of the Previous button after getting to the point where
the messagebox comes up? Is there a line of code I should have here
after the messagebox that "activates" it to allow the Previous
button to work on the 1st click?

Thanks,
J.O.

'This 1st sub is the initial Find
Sub FindViaPOCurrent()
'This is for the PO/PL search via UserForm12. Clicking the OK button
'brings you here. If record found, it opens up UserForm13 to show
'that record. The "Find Another Record" button will also loop back
here.

Worksheets("Official List").Activate
Set rngToSearch = Sheets("Official List").Columns("J")

Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues, _
LookAt:=xlWhole)

If rngFound Is Nothing Then
MsgBox "This record was not found. Make sure you entered the
correct number. Also, check the Deleted List."
Unload UserForm12
UserForm12.Show

Else
strFirst = rngFound.Address
rngFound.Select

Unload UserForm12
UserForm13.Show

End If

End Sub

Sub FindNextViaPOCurrent()
Worksheets("Official List").Activate
Set rngFound = rngToSearch.FindNext(rngFound)
rngFound.Select
If rngFound.Address = strFirst Then
MsgBox "There are no other records with this PO/PL."

Else
Unload UserForm13
UserForm13.Show
End If

End Sub

Sub FindPreviousViaPOCurrent()

Worksheets("Official List").Activate
Set rngFound = rngToSearch.FindPrevious(rngFound)
rngFound.Select

Unload UserForm13
UserForm13.Show

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
Create floating button based on button click in menu ExcelMonkey Excel Programming 2 October 12th 05 06:43 PM
On Button Click(Help!) jpizzle[_2_] Excel Programming 1 June 3rd 05 11:32 AM
Embedded command button doesn't respond in new window Jim Cable Excel Programming 0 February 20th 04 03:38 PM
VBA button click need help. Need LEN help. Nigel Cummins Excel Programming 4 July 11th 03 08:52 PM
VBA button click need help. Need LEN help. Nigel Cummins Excel Programming 0 July 11th 03 09:53 AM


All times are GMT +1. The time now is 06:00 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"