473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Match a Wildcard with the Number Data Type?

I'm trying to make a multi criteria server filter and everything works fine when filtering for strings. When I add a number field to the filterable set I run into problems. Here is the VBScript I'm using.
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language=vbscript>
  2. Function SetServerFilter()
  3. dim myFilter, strCustomer, strJobName, strSalesPerson, strWorkOrder
  4.  
  5. If txtCustomer.value = "" Then
  6. strCustomer = "[Customer Name] like '%'" 
  7. Else
  8. strCustomer = "[Customer Name] = '" & txtCustomer.value & "'"
  9. End If
  10. If txtJobName.value = "" Then
  11. strJobName = "[Job Name] like '%'"
  12. Else
  13. strJobName = "[Job Name] like '%" & txtJobName.value & "%'"    
  14. End If  
  15. If txtSalesPerson.value = "" Then
  16. strSalesPerson = "[SalesPerson] like '%'"
  17. Else
  18. strSalesPerson = "[SalesPerson] = '" & txtSalesPerson.value & "'"
  19. End If
  20. If txtWorkOrder = "" Then
  21. strWorkOrder = "[WO NUMBER] = "   'I tried to leave it blank but this doesn't work.
  22. Else
  23. strWorkOrder = "[WO NUMBER] = " & txtWorkOrder.value
  24. End If
  25.  
  26.       myFilter = strCustomer & "AND"& strSalesPerson & "AND" & strJobName & "AND" & strWorkOrder
  27.  
  28.       txtMyfilter.value = (myFilter)
  29.    MSODSC.RecordsetDefs.Item(0).ServerFilter = myFilter
  30. 'test that doesn't work
  31.    'MSODSC.RecordsetDefs.Item(0).ServerFilter = "[WO NUMBER] = "
  32. End Function
  33.  
  34.  
  35. </SCRIPT>
  36.  
The first three If/Than/Else statements get the appropriate information into the serverfilter via myFilter. However, on the fourth IF/Than/Else statement I don't know how to get a wildcard to match with a number type value.
This string "[Number] = 32218" will work fine but I need something like this "[Number] = any number at all" to get the thing to work. It's either that or I can go back to the table and change the data type for [WO NUMBER] to text.

Thanks for any help you can give me.
James
Oct 24 '07 #1
4 5766
Well, Duh. I like IF/Than/Else statements so much here I simply add this to the code and it works just fine.
Expand|Select|Wrap|Line Numbers
  1. If txtWorkOrder.value = "" Then
  2.       myFilter = strCustomer & "AND"& strSalesPerson & "AND" & strJobName '& "AND" & strWorkOrder
  3. Else
  4. myFilter = strCustomer & "AND"& strSalesPerson & "AND" & strJobName & "AND" & strWorkOrder
  5. End If
  6.  
Oct 24 '07 #2
nico5038
3,080 Expert 2GB
I never code filterings this "extensive", but give my users a description how to use the right-click popup form:
http://www.geocities.com/nico5038/xR...nstruction.zip

Success !

Nic;o)
Oct 25 '07 #3
The built in filter and sort functions are great for forms. I use them everyday when looking for orders, but this function is done in a data access page. There is a record navigation control (in DAPs) that can do some of the things that the filter and sort can do (in forms). This page will be used by many people in our company, and some of them are not very computer literate like you and me. This page kind of resembles a search page they may have used on the internet so they feel more comfortable. Also, I don't have to teach them how to use the navigation button; I actually removed it all together from the page.
Oct 26 '07 #4
nico5038
3,080 Expert 2GB
Hmm, DAP's is a different story indeed. Must warn you that A2007 won't support DAP anymore....

For the number within number test you could try the CStr() function on the number to get a characterstring instead of a number. This combined with Instr() would give you success when the number(s) are found in the number.
Something like:
Expand|Select|Wrap|Line Numbers
  1. select * from tblx WHERE (((InStr(CStr(nz([NumberField])),CStr(55)))>0));
  2.  
The NZ() is only needed when the number can be empty (Null)

Nic;o)
Oct 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
2
by: WjWm | last post by:
Hello all, I'm kind of struggling with numeric data types... I have read alot of material, and think I have a 'decent' grasp on the various number data types and the effects of the scale and...
3
by: Laurel | last post by:
this is driving me crazy. i need to use a form control as a criteria in a select query, and the control's value is set depending upon what a user selects in an option group on the form. the query...
5
by: dananrg | last post by:
I was messing around with the native ODBC module (I am using Python in a Win32 environment), e.g: import dbi, odbc ....and it seems to meet my needs. I'd rather use a module that comes...
2
by: Eric | last post by:
Why it gives that error. Both tables have same type of number Data type mismatch qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM tbl_EquipmentChronology WHERE...
3
bhcob1
by: bhcob1 | last post by:
I have a list which is populated with Fields from a table, I want to be able to determine if the data type of the value selected in the list is Number. Any ideas, i thought there would be something...
5
by: Amit Parmar | last post by:
Hi Everybody, I am fetching number data from a table. i want to add '$' sign to this data. I already tried "TO_CHAR" function. This works fine but it converts number data type to string data...
1
by: foxygrandma | last post by:
I am having data type problems. The first thing I had to do was convert the weight of one column from kg to lb. I did this by multiplying by 2.20462262 and updating a new column, however, the...
2
by: JoeKid09 | last post by:
Hi Guys, I'm working on converting a large table with a field that has numeric values in text data type. When I do the conversion in Access automatically some records don't get converted. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.