Thanks in advance!! I've looked at fConcatFld but that doesn't seem to
be what i'm looking for or I just can't figure it out.
I'm trying to have a button select records based on two combo boxes -
one holding a number and one text.
Floor(combo18) is a floor number and site(combo20) is a building
name
Private Sub Command22_Click ()
Dim strSQL As String
strSQL = "Select * FROM [qryAllSlrSites]"
strSQL = strSQL & "WHERE ((([qryAllSlrSites].[Exclude])=False) AND
((qryAllSlrSite s.Floor)=" & Me.Combo18 & "))"
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
Me.RecordSource = strSQL
End Sub
Is there a good way to make do this? I've been cutting and pasting
SQL statements trying to put fields in where criteria were in the
statement.
-warning e-mail address altered- arthureNOSPACE@ 3 1288
arthur-e wrote: Thanks in advance!! I've looked at fConcatFld but that doesn't seem to be what i'm looking for or I just can't figure it out.
I'm trying to have a button select records based on two combo boxes - one holding a number and one text. Floor(combo18) is a floor number and site(combo20) is a building name
Private Sub Command22_Click () Dim strSQL As String strSQL = "Select * FROM [qryAllSlrSites]"
strSQL = strSQL & "WHERE ((([qryAllSlrSites].[Exclude])=False) AND ((qryAllSlrSite s.Floor)=" & Me.Combo18 & "))"
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
Me.RecordSource = strSQL End Sub
Is there a good way to make do this? I've been cutting and pasting SQL statements trying to put fields in where criteria were in the statement.
-warning e-mail address altered- arthureNOSPACE@
Hmmmm...I might put in the after update event some code like
SetFilter
for each combo box.
THen create a routine
PRivate Sub SetFilter()
Dim strFilter As STring
If Not IsNull(Me.Combo 18) Then
strFilter = "Exclude = False And "
"Floor = " & Me.Combo18 & " And "
ENdif
If Not IsNull(Me.Combo 20) Then
strFilter = strFilter & _
"Site = " & Me.Combo20 & " And "
ENdif
If strFilter > "" Then
'remove the word And
strFilter = Left(strFilter, Len(strFilter) -5)
Me.Filter = strFilter
Me.FilterOn = True
Else
'no filter
Me.Filter = ""
Me.FilterOn = False
ENdif
ENd SUb
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
THANKIS -
interesting concept - I'll give it a try.
The key in your routine seems to be eliminating the last AND if there
isn't one.
I couldn't even got two simple boxes to work together - I couldn't
keep the """""" and ))))) straight.
Arthur
Salad <oi*@vinegar.co m> wrote: arthur-e wrote: Thanks in advance!! I've looked at fConcatFld but that doesn't seem to be what i'm looking for or I just can't figure it out.
I'm trying to have a button select records based on two combo boxes - one holding a number and one text. Floor(combo18) is a floor number and site(combo20) is a building name
Private Sub Command22_Click () Dim strSQL As String strSQL = "Select * FROM [qryAllSlrSites]"
strSQL = strSQL & "WHERE ((([qryAllSlrSites].[Exclude])=False) AND ((qryAllSlrSite s.Floor)=" & Me.Combo18 & "))"
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
Me.RecordSource = strSQL End Sub
Is there a good way to make do this? I've been cutting and pasting SQL statements trying to put fields in where criteria were in the statement.
-warning e-mail address altered- arthureNOSPACE@
Hmmmm...I might put in the after update event some code like SetFilter for each combo box.
THen create a routine
PRivate Sub SetFilter() Dim strFilter As STring If Not IsNull(Me.Combo 18) Then strFilter = "Exclude = False And " "Floor = " & Me.Combo18 & " And " ENdif
If Not IsNull(Me.Combo 20) Then strFilter = strFilter & _ "Site = " & Me.Combo20 & " And " ENdif
If strFilter > "" Then 'remove the word And strFilter = Left(strFilter, Len(strFilter) -5) Me.Filter = strFilter Me.FilterOn = True Else 'no filter Me.Filter = "" Me.FilterOn = False ENdif ENd SUb
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
-warning e-mail address altered- arthureNOSPACE@
arthur-e wrote: THANKIS - interesting concept - I'll give it a try. The key in your routine seems to be eliminating the last AND if there isn't one.
It's a common practice that if you are stringing a bunch of conditions
that are ANDed, to add it to the end of each and then remove at the end.
Makes it easy to debug.
Another key is that if you call the routine from each combo, the list
will shrink or expand. For example, in the AfterUpdate event of the
Major combo (Combo18), you could have the code.
Me.Combo20 = Null
SetFilter
Now you get all of the records for the Floor to be displayed.
Then the minor combo (combo20) enter
SetFilter
in the afterupdate event. I couldn't even got two simple boxes to work together - I couldn't keep the """""" and ))))) straight. Arthur
I know what you mean. :-)
If I copy/paste code from the SQL window in the query builder, there are
so many () I usually head to the "Where" clause and remove them simply
so I can read it easily. Usually the where clause is strung together by
ANDs. The only time I need tha parans is when you have ORs mixed in the
clause.
I was assuming your Combos use numbers. If not, you can add the quotes
as necessary.
Instead of
strFilter = strFilter & "Site = " & Me.Combo20 & " And "
you could use
strFilter = strFilter & "Site = '" & Me.Combo20 & "' And " Salad <oi*@vinegar.co m> wrote:
arthur-e wrote:
Thanks in advance!! I've looked at fConcatFld but that doesn't seem to be what i'm looking for or I just can't figure it out.
I'm trying to have a button select records based on two combo boxes - one holding a number and one text. Floor(combo1 8) is a floor number and site(combo20) is a building name
Private Sub Command22_Click () Dim strSQL As String strSQL = "Select * FROM [qryAllSlrSites]"
strSQL = strSQL & "WHERE ((([qryAllSlrSites].[Exclude])=False) AND ((qryAllSlrS ites.Floor)=" & Me.Combo18 & "))"
strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))"
Me.RecordSou rce = strSQL End Sub
Is there a good way to make do this? I've been cutting and pasting SQL statements trying to put fields in where criteria were in the statement.
-warning e-mail address altered- arthureNOSPACE@
Hmmmm...I might put in the after update event some code like SetFilter for each combo box.
THen create a routine
PRivate Sub SetFilter() Dim strFilter As STring If Not IsNull(Me.Combo 18) Then strFilter = "Exclude = False And " "Floor = " & Me.Combo18 & " And " ENdif
If Not IsNull(Me.Combo 20) Then strFilter = strFilter & _ "Site = " & Me.Combo20 & " And " ENdif
If strFilter > "" Then 'remove the word And strFilter = Left(strFilter, Len(strFilter) -5) Me.Filter = strFilter Me.FilterOn = True Else 'no filter Me.Filter = "" Me.FilterOn = False ENdif ENd SUb strSQL = strSQL & " AND ((qryAllSlrSite s.site)= '" & Me.Combo20 & "))" -warning e-mail address altered- arthureNOSPACE@ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonas Galvez |
last post by:
Is it true that joining the string elements of a list is faster than
concatenating them via the '+' operator?
"".join()
vs
'a'+'b'+'c'
If so, can anyone explain why?
|
by: Paul Davis |
last post by:
I'd like to overload 'comma' to define a concatenation operator for
integer-like classes. I've got some first ideas, but I'd appreciate a
sanity check. The concatenation operator needs to so something like
this:
1) e = (a, b, c, d); // concatenate a,b,c,d into e
2) (a, b, c, d) = e; // get the bits of e into a,b,c, and d
For example, in the second case, assume that a,b,c,d represent 2-bit
integers, and e represents an 8-bit...
|
by: Kevin C |
last post by:
Quick Question:
StringBuilder is obviously more efficient dealing with string concatenations
than the old '+=' method... however, in dealing with relatively large string
concatenations (ie, 20-30k), what are the performance differences (if any
with something as trivial as this) between initializing a new instance of
StringBuilder with a specified capacity vs. initializing a new instance
without... (the final length is not fixed)
ie,
|
by: Caroline |
last post by:
The following is not working
int num = 0,
char *string;
string = "qwerty";
strcpy(string, num);
strcpy(string, ".png");
|
by: michael.casey |
last post by:
The purpose of this post is to obtain the communities opinion of the
usefulness, efficiency, and most importantly the correctness of this
small piece of code. I thank everyone in advance for your time in
considering this post, and for your comments.
I wrote this function to simplify the task of combining strings using
mixed sources. I often see the use of sprintf() which results in
several lines of code, and more processing than really...
| |
by: Bonj |
last post by:
what is the correct form of string concatenation in VB.NET, + or &?
Both seem to work, but which is correct?
I know it's + in C# and & in VB6, but which in VB.NET?
|
by: genc_ymeri |
last post by:
Hi over there,
Propably this subject is discussed over and over several times. I did google
it too but I was a little bit surprised what I read on internet when it
comes 'when to use what'.
Most of articles I read from different experts and programmers tell me that
their "gut feelings" for using stringBuilder instead of string concatenation
is when the number of string concatunation is more then N ( N varies between
3 to max 15 from...
|
by: Larry Hastings |
last post by:
This is such a long posting that I've broken it out into sections.
Note that while developing this patch I discovered a Subtle Bug
in CPython, which I have discussed in its own section below.
____________
THE OVERVIEW
I don't remember where I picked it up, but I remember reading years
ago that the simple, obvious Python approach for string concatenation:
x = "a" + "b"
|
by: Bart Kastermans |
last post by:
Summary: can't verify big O claim, how to properly time this?
On Jun 15, 2:34 pm, "Terry Reedy" <tjre...@udel.eduwrote:
Thanks for the idea. I would expect the separation to lead to
somewhat more
code, but all the "checking the root" code would be separated out in
the
tree class. The node class would be very smooth. I'll try this when
I have
|
by: raylopez99 |
last post by:
StringBuilder better and faster than string for adding many strings.
Look at the below. It's amazing how much faster StringBuilder is than
string.
The last loop below is telling: for adding 200000 strings of 8 char
each, string took over 25 minutes while StringBuilder took 40
milliseconds!
Can anybody explain such a radical difference?
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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: 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: 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...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |