473,804 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing SQL "Like" string from VB code into Query Parameter.

ChaseCox
294 Contributor
I have a Database Called FalconAnalysis. mdb. The table I am wanting to use is called Generic Material. The Query I want to pass the value into is called Material Query. The field in the query is called Order_Model. I would like to pass the result, "strSize", from the following string of code into the Order_Model field of Material Query, which looks at generic Material Table.
Expand|Select|Wrap|Line Numbers
  1. Private Sub MakeFilter2()
  2.  
  3. strSize = ""
  4.  
  5.     If Nz(chkv2125S, False) Then _
  6.             strSize = strSize & ",'150'"
  7.     If Nz(chkv2125H, False) Then _
  8.             strSize = strSize & ",'151'"
  9.     If Nz(chkv215S, False) Then _
  10.             strSize = strSize & ",'180'"
  11.     If Nz(chkv215H, False) Then _
  12.             strSize = strSize & ",'181'"
  13.     If Nz(chkv2175S, False) Then _
  14.             strSize = strSize & ",'210'"
  15.     If Nz(chkv2175H, False) Then _
  16.             strSize = strSize & ",'211'"
  17.     If Nz(chkv220S, False) Then _
  18.             strSize = strSize & ",'240'"
  19.     If Nz(chkv220H, False) Then _
  20.             strSize = strSize & ",'241'"
  21.     If Nz(chkv225S, False) Then _
  22.             strSize = strSize & ",'300'"
  23.     If Nz(chkv225H, False) Then _
  24.             strSize = strSize & ",'301'"
  25.  
  26.  
  27. End Sub
  28.  
I think it should be a like statment, any thoughts on how to do this?
Feb 6 '07
10 3403
nico5038
3,080 Recognized Expert Specialist
Why not create a table with the 150, 151, 180, 181, etc. values in a row and an additional checkbox.
Thus you can let the user check the rows in a datasheet subform and all needed is to join this additional table by the code to this table and add the criteria "True" for the checkbox.

Saves the code and you could use a simple UPDATE query to set/reset the checkbox on the form.

Idea ?

Nic;o)
Feb 7 '07 #11

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

Similar topics

5
48337
by: NK | last post by:
Hi all, Does anyone know of how I can disable case sensitivity for the LIKE function in SQL? Currently the SQL statement looks like: $query = "SELECT * FROM itrader_games WHERE console='$console' AND genre='$genre' AND title LIKE '%$title%' ";
11
3922
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being parsed can completely wreck it. The string I am trying to parse is as follows: commandText=insert into (Text) values (@message + N': ' + @category);commandType=StoredProcedure; message=@message; category=@category I am looking to retrive name value...
10
7598
by: joshsackett | last post by:
I am starting an encryption project for my database and I'm performing some tests on decryption speed. A lot of my application queries use a LIKE parameter in the WHERE clause. To keep from changing my application I am performing all the work on the back-end; creating views, triggers and UDFs to encrypt/decrypt the data. A problem has arisen around the LIKE parameter, though. Currently: SELECT SSN, FNAME, LNAME FROM USERS WHERE LNAME...
2
13364
by: Dave Smithz | last post by:
Hello there, Summary: How far can you go with SQL Select queries using like clauses with wildcard characters. Can you apply anything like regular expressions? Full details: On a Intranet website, I request a code from a user which is then compared with a code in an ADO access database.
1
3392
by: S. van Beek | last post by:
Dear reader, How can I filter a numeric field with Like as criteria in a query. To filter a numeric field with <10 as criteria this will com back with the result of those records for which the value is smaller as teen. But in case this value is variable and you prefer to work with "Like
4
1958
by: mosscliffe | last post by:
I have been messing with the above all afternoon. I must just be thick I am using an AccessDataSource I have tried modifying the select but I can not find the right syntax to concatenate the LIKE part of the test by surrounding my textbox field value with a leading and closing %.
11
6410
by: Bruce Lawrence | last post by:
Ok, I'm baffled... I'm making a query in access 97 between 2 tables. There is a field in both tables called "DWGNO". OPENORD has a record with a DWGNO of "00000012345" DIEDATA has a record with a DWGNO of "12345" I'm not doing this with VBA right now. I'm doing it through the query gui.
9
2449
by: Drum2001 | last post by:
Hello All! I am using the following code during an On Click event for a button. It works properly to create a query for a report: Private Sub Command14_Click() If IsNull(Me.Text30) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text30.Value & "'"
7
2451
by: MLH | last post by:
If I drop Like "*ABC*" in a QBE grid criteria cell, the records returned include mixed case. Can I force the uppercase limitation in a QBE grid?
0
9575
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7609
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.