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.Text3 0) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text30.Value & "'"
End If
If IsNull(Me.Text3 1) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text31.Value & "'"
End If
If IsNull(Me.Text3 2) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text32.Value & "'"
End If
If IsNull(Me.Text3 3) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text33.Value & "'"
End If
If IsNull(Me.Text3 4) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text34.Value & "'"
End If
If IsNull(Me.Text3 5) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text35.Value & "'"
End If
If IsNull(Me.Text3 6) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text36.Value & "'"
End If
If IsNull(Me.Text3 7) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text37.Value & "'"
End If
If Len(strWhere) 1 Then
strWhere = Mid$(strWhere, 2)
strWhere = "AC IN (" & strWhere & ")"
'strWhere = "" & strLike & " AC IN (" & strWhere & ")"
End If
DoCmd.OpenRepor t "qryAm", acViewPreview, , strWhere
End Sub
----------------------------------
The line I would specifically like to ask about is the following:
strWhere = "AC IN (" & strWhere & ")"
How would I include a "Like" in the string?
Psuedocode - AC IN LIKE *strWhwere*
Thank you in advance!
Brad 9 2447
Drum2001 wrote:
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.Text3 0) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text30.Value & "'"
End If
If IsNull(Me.Text3 1) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text31.Value & "'"
End If
If IsNull(Me.Text3 2) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text32.Value & "'"
End If
If IsNull(Me.Text3 3) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text33.Value & "'"
End If
If IsNull(Me.Text3 4) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text34.Value & "'"
End If
If IsNull(Me.Text3 5) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text35.Value & "'"
End If
If IsNull(Me.Text3 6) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text36.Value & "'"
End If
If IsNull(Me.Text3 7) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text37.Value & "'"
End If
If Len(strWhere) 1 Then
strWhere = Mid$(strWhere, 2)
strWhere = "AC IN (" & strWhere & ")"
'strWhere = "" & strLike & " AC IN (" & strWhere & ")"
End If
DoCmd.OpenRepor t "qryAm", acViewPreview, , strWhere
End Sub
----------------------------------
The line I would specifically like to ask about is the following:
strWhere = "AC IN (" & strWhere & ")"
How would I include a "Like" in the string?
Psuedocode - AC IN LIKE *strWhwere*
Thank you in advance!
Brad
Why not make your query use ORs instead
StrWhere = AC Like "Test*" Or
AC Like "Question*" Or
AC Like "Answer*"
Would that be static?
Users are not always going to enter information in every textbox.
If not, how would I exactly code the strWhere?
salad wrote:
Drum2001 wrote:
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.Text3 0) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text30.Value & "'"
End If
If IsNull(Me.Text3 1) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text31.Value & "'"
End If
If IsNull(Me.Text3 2) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text32.Value & "'"
End If
If IsNull(Me.Text3 3) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text33.Value & "'"
End If
If IsNull(Me.Text3 4) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text34.Value & "'"
End If
If IsNull(Me.Text3 5) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text35.Value & "'"
End If
If IsNull(Me.Text3 6) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text36.Value & "'"
End If
If IsNull(Me.Text3 7) Then
' No criteria here - so ignore
Else
strWhere = strWhere & ",'" & Me.Text37.Value & "'"
End If
If Len(strWhere) 1 Then
strWhere = Mid$(strWhere, 2)
strWhere = "AC IN (" & strWhere & ")"
'strWhere = "" & strLike & " AC IN (" & strWhere & ")"
End If
DoCmd.OpenRepor t "qryAm", acViewPreview, , strWhere
End Sub
----------------------------------
The line I would specifically like to ask about is the following:
strWhere = "AC IN (" & strWhere & ")"
How would I include a "Like" in the string?
Psuedocode - AC IN LIKE *strWhwere*
Thank you in advance!
Brad
Why not make your query use ORs instead
StrWhere = AC Like "Test*" Or
AC Like "Question*" Or
AC Like "Answer*"
Drum2001 wrote:
Would that be static?
Users are not always going to enter information in every textbox.
If not, how would I exactly code the strWhere?
salad wrote:
>>Drum2001 wrote:
>>>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.Text3 0) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text30.Value & "'" End If
If IsNull(Me.Text3 1) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text31.Value & "'" End If
If IsNull(Me.Text3 2) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text32.Value & "'" End If
If IsNull(Me.Text3 3) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text33.Value & "'" End If
If IsNull(Me.Text3 4) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text34.Value & "'" End If
If IsNull(Me.Text3 5) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text35.Value & "'" End If
If IsNull(Me.Text3 6) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text36.Value & "'" End If
If IsNull(Me.Text3 7) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text37.Value & "'" End If
If Len(strWhere) 1 Then
strWhere = Mid$(strWhere, 2) strWhere = "AC IN (" & strWhere & ")" 'strWhere = "" & strLike & " AC IN (" & strWhere & ")"
End If
DoCmd.OpenRe port "qryAm", acViewPreview, , strWhere
End Sub
----------------------------------
The line I would specifically like to ask about is the following:
strWhere = "AC IN (" & strWhere & ")"
How would I include a "Like" in the string? Psuedocode - AC IN LIKE *strWhwere*
Thank you in advance!
Brad Why not make your query use ORs instead StrWhere = AC Like "Test*" Or AC Like "Question*" Or AC Like "Answer*"
Looking at the code you have up above you do check 3 or 4 checkboxes.
If Not IsNull(x) Then
strWhere = "AC Like '" & x & "' Or "
ENdif
If Not IsNull(y) Then
strWhere = "AC Like '" & y & "' Or "
ENdif
'remove the OR
strWhere = Left(strWhere,L en(strWHere)-4)
When I use this code, it only searches one textbox. It is the one that
it uses last.. Seems like its overwrighting. This is what I have:
------------------------------------------------------------------------------------------------
Private Sub Command14_Click ()
If Not IsNull(Me.Text3 0) Then
strWHere = "ACLike '" & Me.Text30 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 1) Then
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 2) Then
strWHere = "AC Like '" & Me.Text32 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 3) Then
strWHere = "ACLike '" & Me.Text33 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 4) Then
strWHere = "AC Like '" & Me.Text34 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 5) Then
strWHere = "AC Like '" & Me.Text35 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 6) Then
strWHere = "AC Like '" & Me.Text36 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 7) Then
strWHere = "AC Like '" & Me.Text37 & "'"
End If
'remove the OR
strWHere = Left(strWHere, Len(strWHere) - 4)
DoCmd.OpenRepor t "qryAcronym ", acViewPreview, , strWHere
End Sub
------------------------------------------------------------------------------------------------
Any suggestions? I really appreciate your assistance!
Brad
salad wrote:
Drum2001 wrote:
Would that be static?
Users are not always going to enter information in every textbox.
If not, how would I exactly code the strWhere?
salad wrote:
>Drum2001 wrote:
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.Text3 0) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text30.Value & "'" End If
If IsNull(Me.Text3 1) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text31.Value & "'" End If
If IsNull(Me.Text3 2) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text32.Value & "'" End If
If IsNull(Me.Text3 3) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text33.Value & "'" End If
If IsNull(Me.Text3 4) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text34.Value & "'" End If
If IsNull(Me.Text3 5) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text35.Value & "'" End If
If IsNull(Me.Text3 6) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text36.Value & "'" End If
If IsNull(Me.Text3 7) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text37.Value & "'" End If
If Len(strWhere) 1 Then
strWhere = Mid$(strWhere, 2) strWhere = "AC IN (" & strWhere & ")" 'strWhere = "" & strLike & " AC IN (" & strWhere & ")"
End If
DoCmd.OpenRep ort "qryAm", acViewPreview, , strWhere
End Sub
----------------------------------
The line I would specifically like to ask about is the following:
strWhere = "AC IN (" & strWhere & ")"
How would I include a "Like" in the string? Psuedocode - AC IN LIKE *strWhwere*
Thank you in advance!
Brad
Why not make your query use ORs instead StrWhere = AC Like "Test*" Or AC Like "Question*" Or AC Like "Answer*"
Looking at the code you have up above you do check 3 or 4 checkboxes.
If Not IsNull(x) Then
strWhere = "AC Like '" & x & "' Or "
ENdif
If Not IsNull(y) Then
strWhere = "AC Like '" & y & "' Or "
ENdif
'remove the OR
strWhere = Left(strWhere,L en(strWHere)-4)
Drum2001 wrote:
When I use this code, it only searches one textbox. It is the one that
it uses last.. Seems like its overwrighting. This is what I have:
------------------------------------------------------------------------------------------------
Private Sub Command14_Click ()
If Not IsNull(Me.Text3 0) Then
strWHere = "ACLike '" & Me.Text30 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 1) Then
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 2) Then
strWHere = "AC Like '" & Me.Text32 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 3) Then
strWHere = "ACLike '" & Me.Text33 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 4) Then
strWHere = "AC Like '" & Me.Text34 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 5) Then
strWHere = "AC Like '" & Me.Text35 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 6) Then
strWHere = "AC Like '" & Me.Text36 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 7) Then
strWHere = "AC Like '" & Me.Text37 & "'"
End If
'remove the OR
strWHere = Left(strWHere, Len(strWHere) - 4)
DoCmd.OpenRepor t "qryAcronym ", acViewPreview, , strWHere
End Sub
------------------------------------------------------------------------------------------------
Any suggestions? I really appreciate your assistance!
Brad
You need to replace "strWHere = " with "strWHere = strWhere & " in your
code.
Bruce
Drum2001 wrote:
When I use this code, it only searches one textbox. It is the one that
it uses last.. Seems like its overwrighting. This is what I have:
------------------------------------------------------------------------------------------------
Private Sub Command14_Click ()
If Not IsNull(Me.Text3 0) Then
strWHere = "ACLike '" & Me.Text30 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 1) Then
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
End If
<snip>
First of all your form object naming convention, or lack of one sucks. 8)
But to address your problem, your code is rewriting the whole of
strWhere everytime an if statement is executed. To fix what you have,
on the second if statement shown above, and all the remaining ones replace:
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
with
strWHere = strwhere & "ACLike '" & Me.Text31 & "*" & "' Or "
That will do it.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Tim Marshall wrote:
Drum2001 wrote:
>When I use this code, it only searches one textbox. It is the one that it uses last.. Seems like its overwrighting. This is what I have:
------------------------------------------------------------------------------------------------
Private Sub Command14_Click () If Not IsNull(Me.Text3 0) Then strWHere = "ACLike '" & Me.Text30 & "*" & "' Or " End If
If Not IsNull(Me.Text3 1) Then strWHere = "ACLike '" & Me.Text31 & "*" & "' Or " End If
<snip>
First of all your form object naming convention, or lack of one sucks. 8)
I would be constantly wondering what Textxx and Textyy were. Debugging
time would be high in a serious application.
But to address your problem, your code is rewriting the whole of
strWhere everytime an if statement is executed. To fix what you have,
on the second if statement shown above, and all the remaining ones replace:
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
with
strWHere = strwhere & "ACLike '" & Me.Text31 & "*" & "' Or "
That will do it.
DOH! Thanks Tim and Deluxe for spotting the logic error.
EXCELLENT!!!
THANK YOU ALL FOR YOUR ASSISTANCE!!!
Tim Marshall wrote:
Drum2001 wrote:
When I use this code, it only searches one textbox. It is the one that
it uses last.. Seems like its overwrighting. This is what I have:
------------------------------------------------------------------------------------------------
Private Sub Command14_Click ()
If Not IsNull(Me.Text3 0) Then
strWHere = "ACLike '" & Me.Text30 & "*" & "' Or "
End If
If Not IsNull(Me.Text3 1) Then
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
End If
<snip>
First of all your form object naming convention, or lack of one sucks. 8)
But to address your problem, your code is rewriting the whole of
strWhere everytime an if statement is executed. To fix what you have,
on the second if statement shown above, and all the remaining ones replace:
strWHere = "ACLike '" & Me.Text31 & "*" & "' Or "
with
strWHere = strwhere & "ACLike '" & Me.Text31 & "*" & "' Or "
That will do it.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
salad wrote:
DOH! Thanks Tim and Deluxe for spotting the logic error.
Sorry salad, I read the post and didn't notice the "Re" - I thought it
was a first post. Didn't mean to jump in on you. 8)
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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%' ";
|
by: Alastair |
last post by:
Hello guys,
I've been building a search facility for an intranet site I'm part of
developing and we've been building a search engine using Index Server.
It mostly works, however there have been a few niggling problems and
fixing it seems to be a case of patching errors as we find them so I'm
thinking that it might be worth starting the logic from scratch and
rebuilding this again.
Basically we have a simple search, which is simply a...
|
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...
|
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.
|
by: Rick Brown |
last post by:
I'm trying to scan a barcode that contains the text string
"BPWOT08762" into a textbox for use in a DLookup or query grid.
I want to look thru a table's field that contains the last 6
characters of the barcode plus a 1 character prefix.
Test Data in table:
SerialNumber
| |
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.
|
by: brino |
last post by:
hi all !
i want to use the "like" function in a query but i want the user to
enter the search variable.
i have tried "like" but this doesnt return any
results for some reason.
any ideas ???
thanks
brino
|
by: ChaseCox |
last post by:
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.
Private Sub MakeFilter2()
strSize = ""
If Nz(chkv2125S,...
|
by: teddysnips |
last post by:
I am just getting to grips with LINQ to SQL and my first attempt is to
create a Search form.
I need the LINQ to generate SQL like this:
SELECT * FROM CustomerTable WHERE Surname LIKE 'S%'
My LINQ so far looks like this:
var cons = from c in db.CustomerTable
|
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,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |