Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Multiple Search Criteria - One works other does not.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mrmunka@gmail.com - 17 Sep 2007 20:25 GMT
Type:
User Input form

Problem #1:
Multiple search criteria is partially working. AppDate.Value works
fine, however the following error comes up when it reaches the second
criteria, AppDate.Value. The columns (F & G) are single numbers and
are entered via a drop down list via another input form.

[F: Month] [G: Day]
    7              1

Error:
Run-time Error (91)
Object variable or With block variable not set.

Problem #2:
I have yet to find a way to set the row with the found results and the
first cell as the active cell to start editing. I can  set the offset
value easy enough, however the cell number is dynamic and most often
will not be the same.

Code:
Private Sub Search_Click()
   Dim wks As Worksheet
   Dim wks2 As Worksheet
   Dim FoundCell As Range
   Dim FoundCell2 As Range

   Set wks = Worksheets("Appointment Log")
   If Me.ClientNum.Value = "" And Me.AppDate.Value = "" Then
       MsgBox "You must enter a Client # and Appointment Date it was
set for!"
       Exit Sub
   End If

   With wks
       With .Range("C:D") '*** Columns to look in, unable to set to a
single column? ***'
           Set FoundCell = .Cells.Find(what:=Me.ClientNum.Value, _
                               after:=.Cells(.Cells.Count), _
                               LookIn:=xlFormulas, _
                               Lookat:=xlPart, _
                               searchorder:=xlByRows, _
                               searchdirection:=xlNext, _
                               MatchCase:=False)
       End With
   End With

   With wks2
       With .Range("F:G") '***Columns to look in.***'
           Set FoundCell2 = .Cells.Find(what:=Me.AppDate.Value, _
                               after:=.Cells(.Cells.Count), _
                               LookIn:=xlFormulas, _
                               Lookat:=xlPart, _
                               searchorder:=xlByRows, _
                               searchdirection:=xlNext, _
                               MatchCase:=False)
       End With
   End With

   If FoundCell And FoundCell2 Is Nothing Then
       MsgBox "Not found, please try again."
   Else
       MsgBox "Found it! Input Fields are now enabled, please enter
your results below."
       DealClosed.Enabled = True '1st Cell to be edited, Column L
       DealClosed.SetFocus
       ClientClosed.Enabled = True '2nd Cell to be edited, Column M
       Showed.Enabled = True '3rd Cell to be edited, Column N
       Closed.Enabled = True '4th Cell to be edited, Column O
       Notes.Enabled = True '5th Cell to be edited, Column P
       FrontGross.Enabled = True '6th Cell to be edited, Column Q
       BackGross.Enabled = True '7th Cell to be edited, Column R
       SaveB.Enabled = True '8th Cell to be edited, Column S

   End If

End Sub

Thanks in advance for any help provided, it is greatly appreciated!
mrmunka@gmail.com - 17 Sep 2007 20:29 GMT
Correction:
Problem #1:
Multiple search criteria is partially working. ClientNum.Value works
fine, however the following error comes up when it reaches the second
criteria, AppDate.Value. The columns (F & G) are single numbers and
are entered via a drop down list via another input form.

(ClientNum.Value is the correction)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.