LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Load 2nd form - second one not working after hide - help pls

I have a user form that is used as an input/dialog box asking for Job Number
to search by... Once entered and OK is pressed.. it loads another form that
Displays the Information based on the search (from there the user can make
changes/delete the record).. This works fine.. The problem is when I use a
command button to Perform another Search... located on the Displayed
Information form so that they can look for more records.. rather than
completely exiting out of the forms.. I hide my Search form upon leaving the
Search form (if I completely unload.. same problem) and load/displaying the
Display the Information form. I want to use a command button the Display the
Information form to load the Search form again and close the current form. I
get an error message each time.. 'Run-time 361 Can't load or unload this
object' upon trying load/show the search form again..

i.e.
Private Sub cmdSearchAgain_Click()

' Save form contents before closing:
SaveRow

'Convert the date columns so they will reflect properly
Convert_Text_Numbers

'reset the print area
Set_Print_Area

frmJobSearchDisplay.Hide
Load frmSearch
frmSearch.Show
Unload frmJobSearchDisplay

End Sub

I am perplexed.. It has to be right in front of me.. the error.. but I can't
see it... When I go to this form from frmSearch the code is as follows:

Dim Completed As Boolean

Dim FoundCell As Object
Dim CompleteSheet
Dim rngWholebook As Range
Dim LastRow As Integer 'This is the LAST Non Empty Row
Dim sMessage As String
Dim TrimJobField As String
Completed = True

If Len(txtSearchJobNumber) < 1 Then
Completed = False
End If

Worksheets("Job Number List").Activate

If Completed = False Then
MsgBox "You have left the Job Number field blank.. Please try again."
txtSearchJobNumber.SetFocus
Else
'find the last row
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

'set FoundCell by searching only in the Job field column
Set FoundCell = Worksheets("Job Number List").Range("B1" & ":" & "B" &
LastRow).Find(frmSearch.txtSearchJobNumber)
If FoundCell Is Nothing Then
sMessage = "Sorry... Job Number: " + txtSearchJobNumber.Text + "
was Not Found. Try again?"
If MsgBox(sMessage, vbQuestion + vbYesNo, _
"Search") = vbYes Then
frmSearch.txtSearchJobNumber = vbNullString
frmSearch.txtSearchJobNumber.SetFocus
Else
frmSearch.Hide
Unload frmSearch
Set frmSearch = Nothing
End If
Else
frmSearch.Hide
frmJobSearchDisplay.txtSearchJobNumber = frmSearch.txtSearchJobNumber
Load frmJobSearchDisplay

' Increment row number:
frmJobSearchDisplay.lCurrentRow = FoundCell.Row
frmJobSearchDisplay.Show
Unload frmSearch

End If
End If



 
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
User Form - how to load it Balan Excel Discussion (Misc queries) 4 May 20th 08 12:39 PM
how to hide a form button in a worksheet angie ng Excel Discussion (Misc queries) 1 May 21st 07 01:08 PM
Load form when workbook opens [email protected] Excel Discussion (Misc queries) 2 July 19th 06 03:32 AM
Load and Unload Form commands R Avery Excel Programming 4 July 29th 04 03:16 PM
Form wont hide Tom Ogilvy Excel Programming 1 June 3rd 04 09:21 PM


All times are GMT +1. The time now is 12:32 PM.

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

About Us

"It's about Microsoft Excel"