From: Afrosheen via AccessMonster.com on 14 Apr 2010 20:56 I have two fields. [desc] for description of an item, and [assignedto1] which is the person the item is assigned to. What I want to do is to separate the two. The code that's displayed works ok. 80 strWhere = "[desc] like""" & txtSearch & _ """ and [assignedto1]=""" & Str & """" 90 Filter = strWhere 100 FilterOn = True The thing is that the second part of the code on line 80 I may or may not need. For example: The code field [desc] may equal to hold the txtSearch or "Book*" and the [assignedto1] holds the name of the person that uses the item. Like I said, it works ok. What I'd like to do is if I enter the [desc] like book* and there is no [assignedo1] information then skip the rest of the code. Is there a way of doing this? I know using this code: strWhere = "[desc] Like '" & Me!txtSearch & "'" will do the single search or filter. So I guess I want to do one or the other through code. Thank you for your help again. It's really appreciated. -- Message posted via http://www.accessmonster.com
From: PieterLinden via AccessMonster.com on 14 Apr 2010 21:16 Afrosheen wrote: >I have two fields. [desc] for description of an item, and [assignedto1] which >is the person the item is assigned to. What I want to do is to separate the >two. > >The code that's displayed works ok. >80 strWhere = "[desc] like""" & txtSearch & _ > """ and [assignedto1]=""" & Str & """" >90 Filter = strWhere >100 FilterOn = True > >The thing is that the second part of the code on line 80 I may or may not >need. > >For example: The code field [desc] may equal to hold the txtSearch or "Book*" >and the [assignedto1] holds the name of the person that uses the item. Like I >said, it works ok. > >What I'd like to do is if I enter the [desc] like book* and there is no >[assignedo1] information then skip the rest of the code. Is there a way of >doing this? I know using this code: > >strWhere = "[desc] Like '" & Me!txtSearch & "'" will do the single search or >filter. > >So I guess I want to do one or the other through code. > >Thank you for your help again. It's really appreciated. >What I'd like to do is if I enter the [desc] like book* and there is no >[assignedo1] information then skip the rest of the code. Is there a way of >doing this? You must be standing too close to see it... take a couple of steps back. ' build mandatory/always clause here... strWhere = .... 'then add optional part based on what's chosen in the textbox... If Not IsNull(Me![AssignedTo]) strWhere = strWhere & " AND [assignedTo1]=' " & me.cboAssignedTo &" ' " End If -- Message posted via http://www.accessmonster.com
From: Afrosheen via AccessMonster.com on 15 Apr 2010 07:49 Thanks for getting back to me. I'll try it out on Monday. I'm on vacation for the next couple of days. PieterLinden wrote: >>I have two fields. [desc] for description of an item, and [assignedto1] which >>is the person the item is assigned to. What I want to do is to separate the >[quoted text clipped - 23 lines] >> >>Thank you for your help again. It's really appreciated. > >>What I'd like to do is if I enter the [desc] like book* and there is no >>[assignedo1] information then skip the rest of the code. Is there a way of >>doing this? > >You must be standing too close to see it... take a couple of steps back. >' build mandatory/always clause here... >strWhere = .... > >'then add optional part based on what's chosen in the textbox... >If Not IsNull(Me![AssignedTo]) > strWhere = strWhere & " AND [assignedTo1]=' " & me.cboAssignedTo &" ' " >End If -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201004/1
|
Pages: 1 Prev: Building a "save form and open next form" button macro Next: Chart source setting with VBA |