Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
User Form - how to load it | Excel Discussion (Misc queries) | |||
how to hide a form button in a worksheet | Excel Discussion (Misc queries) | |||
Load form when workbook opens | Excel Discussion (Misc queries) | |||
Load and Unload Form commands | Excel Programming | |||
Form wont hide | Excel Programming |