I have one multiselect box called 'listclient.' I have another
multi-select box called 'listemployee.' I found some code that allows
me to query on the listclient box. I'm trying to figure out how to get
my query to query on the listemployee box as well. Thanks in advance
for any help.
Here's my code for querying on the listclient box:
Private Sub cmdRunQuery_Cli ck()
On Error GoTo Err_cmdRunQuery _Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strWhere As String
Dim i As Integer
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = "SELECT
datetest1_tbl.f ld_year,datetes t1_tbl.fld_day, datetest1_tbl.f ld_month,datete st1_tbl.fld_bre ak_mins,datetes t1_tbl.fld_brea k_hrs,datetest1 _tbl.fld_date,d atetest1_tbl.fl d_client,datete st1_tbl.fld_pro ject,datetest1_ tbl.fld_subproj ect,datetest1_t bl.fld_currency ,
datetest1_tbl.f ld_duration_hrs ,datetest1_tbl. fld_duration_mi ns,
datetest1_tbl.f ld_note, datetest1_tbl.f ld_rate,
datetest1_tbl.f ld_amount FROM datetest1_tbl "
strWhere = "Where ((datetest1_tbl .fld_date) Between
Forms!aspdash_f orm!date1 And Forms!aspdash_f orm!date2) and
datetest1_tbl.f ld_client IN ("
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" & listclient.Colu mn(0, i) & "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
strSQL = strSQL & strWhere
MsgBox strSQL
'*** delete the previous query
db.QueryDefs.de lete "qryMyQuery "
Set qdf = db.CreateQueryD ef("qryMyQuery" , strSQL)
'*** open the query
'*** DoCmd.OpenQuery "qryMyQuery ", acNormal, acEdit
Exit_cmdRunQuer y_Click:
Exit Sub
Err_cmdRunQuery _Click:
If Err.Number = 3265 Then '*** if the error is the query is
missing
Resume Next '*** then skip the delete line and
resume on the next line
Else
MsgBox Err.Description '*** write out the error and exit
the sub
Resume Exit_cmdRunQuer y_Click
End If
End Sub 4 1611
"gambit32" <so************ **@gmail.comwro te in
news:11******** **************@ i3g2000cwc.goog legroups.com:
I have one multiselect box called 'listclient.' I have
another multi-select box called 'listemployee.' I found some
code that allows me to query on the listclient box. I'm
trying to figure out how to get my query to query on the
listemployee box as well. Thanks in advance for any help.
Telling you how to modify the code wouldn't be helping you. You
have to learn a little bit about what the code does. Take a few
minutes to read the code and figure out what the existing code
does. Highlight any keyword, press F1, and Access will give you
some information.
Once you understand the code, the answer to your question will
be so obvious that you will be saying Doh!!!
Hint: look for the name of your Client listbox, you would handle
the employee listbox the same way.
Here's my code for querying on the listclient box:
Private Sub cmdRunQuery_Cli ck()
On Error GoTo Err_cmdRunQuery _Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strWhere As String
Dim i As Integer
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = "SELECT
datetest1_tbl.f ld_year,datetes t1_tbl.fld_day, datetest1
_tbl.fld_
month,datetest1 _tbl.fld_break_ mins,datetest1
_tbl.fld_break_ hrs,
datetest1_tbl.f ld_date,datetes t1_tbl.fld_clie nt,datetest1
_tbl.f
ld_project,date test1_tbl.fld_s ubproject,datet est1
_tbl.fld_curre
ncy,
datetest1_tbl.f ld_duration_hrs ,datetest1
_tbl.fld_durati on_mins,
datetest1_tbl.f ld_note, datetest1_tbl.f ld_rate,
datetest1_tbl.f ld_amount FROM datetest1_tbl "
strWhere = "Where ((datetest1_tbl .fld_date) Between
Forms!aspdash_f orm!date1 And Forms!aspdash_f orm!date2) and
datetest1_tbl.f ld_client IN ("
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" & listclient.Colu mn(0, i) &
"', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
strSQL = strSQL & strWhere
MsgBox strSQL
'*** delete the previous query
db.QueryDefs.de lete "qryMyQuery "
Set qdf = db.CreateQueryD ef("qryMyQuery" , strSQL)
'*** open the query
'*** DoCmd.OpenQuery "qryMyQuery ", acNormal, acEdit
Exit_cmdRunQuer y_Click:
Exit Sub
Err_cmdRunQuery _Click:
If Err.Number = 3265 Then '*** if the error is the query
is
missing
Resume Next '*** then skip the delete line
and
resume on the next line
Else
MsgBox Err.Description '*** write out the error
and exit
the sub
Resume Exit_cmdRunQuer y_Click
End If
End Sub
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
I understand the code. I was just curious where to insert the code for
the other list box. I'll give it a go today and post my results.
Thanks!
Bob Quintal wrote:
"gambit32" <so************ **@gmail.comwro te in
news:11******** **************@ i3g2000cwc.goog legroups.com:
I have one multiselect box called 'listclient.' I have
another multi-select box called 'listemployee.' I found some
code that allows me to query on the listclient box. I'm
trying to figure out how to get my query to query on the
listemployee box as well. Thanks in advance for any help.
Telling you how to modify the code wouldn't be helping you. You
have to learn a little bit about what the code does. Take a few
minutes to read the code and figure out what the existing code
does. Highlight any keyword, press F1, and Access will give you
some information.
Once you understand the code, the answer to your question will
be so obvious that you will be saying Doh!!!
Hint: look for the name of your Client listbox, you would handle
the employee listbox the same way.
Here's my code for querying on the listclient box:
Private Sub cmdRunQuery_Cli ck()
On Error GoTo Err_cmdRunQuery _Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strWhere As String
Dim i As Integer
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = "SELECT
datetest1_tbl.f ld_year,datetes t1_tbl.fld_day, datetest1
_tbl.fld_
month,datetest1 _tbl.fld_break_ mins,datetest1
_tbl.fld_break_ hrs,
datetest1_tbl.f ld_date,datetes t1_tbl.fld_clie nt,datetest1
_tbl.f
ld_project,date test1_tbl.fld_s ubproject,datet est1
_tbl.fld_curre
ncy,
datetest1_tbl.f ld_duration_hrs ,datetest1
_tbl.fld_durati on_mins,
datetest1_tbl.f ld_note, datetest1_tbl.f ld_rate,
datetest1_tbl.f ld_amount FROM datetest1_tbl "
strWhere = "Where ((datetest1_tbl .fld_date) Between
Forms!aspdash_f orm!date1 And Forms!aspdash_f orm!date2) and
datetest1_tbl.f ld_client IN ("
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" & listclient.Colu mn(0, i) &
"', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
strSQL = strSQL & strWhere
MsgBox strSQL
'*** delete the previous query
db.QueryDefs.de lete "qryMyQuery "
Set qdf = db.CreateQueryD ef("qryMyQuery" , strSQL)
'*** open the query
'*** DoCmd.OpenQuery "qryMyQuery ", acNormal, acEdit
Exit_cmdRunQuer y_Click:
Exit Sub
Err_cmdRunQuery _Click:
If Err.Number = 3265 Then '*** if the error is the query
is
missing
Resume Next '*** then skip the delete line
and
resume on the next line
Else
MsgBox Err.Description '*** write out the error
and exit
the sub
Resume Exit_cmdRunQuer y_Click
End If
End Sub
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Should I be using strWhere2? Am I on the right track?
gambit32 wrote:
I understand the code. I was just curious where to insert the code for
the other list box. I'll give it a go today and post my results.
Thanks!
Bob Quintal wrote:
"gambit32" <so************ **@gmail.comwro te in
news:11******** **************@ i3g2000cwc.goog legroups.com:
I have one multiselect box called 'listclient.' I have
another multi-select box called 'listemployee.' I found some
code that allows me to query on the listclient box. I'm
trying to figure out how to get my query to query on the
listemployee box as well. Thanks in advance for any help.
>
Telling you how to modify the code wouldn't be helping you. You
have to learn a little bit about what the code does. Take a few
minutes to read the code and figure out what the existing code
does. Highlight any keyword, press F1, and Access will give you
some information.
Once you understand the code, the answer to your question will
be so obvious that you will be saying Doh!!!
Hint: look for the name of your Client listbox, you would handle
the employee listbox the same way.
Here's my code for querying on the listclient box:
>
Private Sub cmdRunQuery_Cli ck()
On Error GoTo Err_cmdRunQuery _Click
>
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strWhere As String
Dim i As Integer
>
Set db = CurrentDb
>
'*** create the query based on the information on the form
strSQL = "SELECT
datetest1_tbl.f ld_year,datetes t1_tbl.fld_day, datetest1
_tbl.fld_
month,datetest1 _tbl.fld_break_ mins,datetest1
_tbl.fld_break_ hrs,
datetest1_tbl.f ld_date,datetes t1_tbl.fld_clie nt,datetest1
_tbl.f
ld_project,date test1_tbl.fld_s ubproject,datet est1
_tbl.fld_curre
ncy,
datetest1_tbl.f ld_duration_hrs ,datetest1
_tbl.fld_durati on_mins,
datetest1_tbl.f ld_note, datetest1_tbl.f ld_rate,
datetest1_tbl.f ld_amount FROM datetest1_tbl "
strWhere = "Where ((datetest1_tbl .fld_date) Between
Forms!aspdash_f orm!date1 And Forms!aspdash_f orm!date2) and
datetest1_tbl.f ld_client IN ("
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" & listclient.Colu mn(0, i) &
"', "
End If
>
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
strSQL = strSQL & strWhere
MsgBox strSQL
>
>
'*** delete the previous query
db.QueryDefs.de lete "qryMyQuery "
Set qdf = db.CreateQueryD ef("qryMyQuery" , strSQL)
>
'*** open the query
'*** DoCmd.OpenQuery "qryMyQuery ", acNormal, acEdit
>
Exit_cmdRunQuer y_Click:
Exit Sub
>
Err_cmdRunQuery _Click:
If Err.Number = 3265 Then '*** if the error is the query
is
missing
Resume Next '*** then skip the delete line
and
resume on the next line
Else
MsgBox Err.Description '*** write out the error
and exit
the sub
Resume Exit_cmdRunQuer y_Click
End If
End Sub
>
>
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
"gambit32" <so************ **@gmail.comwro te in
news:11******** **************@ h48g2000cwc.goo glegroups.com:
I understand the code. I was just curious where to insert the
code for the other list box. I'll give it a go today and post
my results.
If you understood the code, you would not need to ask where to
put the second listbox code.
Existing code:
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" _
& listclient.Colu mn(0, i) _
& "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
'New code to put right after.:
strWhere = strWhere & " AND datetest1_tbl.f ld_employee IN ("
For i = 0 To listemployee.Li stCount - 1
If listemployee.Se lected(i) Then
strWhere = strWhere & "'" _
& listemployee.Co lumn(0, i) _
& "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
>
Thanks!
Bob Quintal wrote:
>"gambit32" <so************ **@gmail.comwro te in news:11******* *************** @i3g2000cwc.goo glegroups.com:
I have one multiselect box called 'listclient.' I have
another multi-select box called 'listemployee.' I found
some code that allows me to query on the listclient box.
I'm trying to figure out how to get my query to query on
the listemployee box as well. Thanks in advance for any
help.
Telling you how to modify the code wouldn't be helping you. You have to learn a little bit about what the code does. Take a few minutes to read the code and figure out what the existing code does. Highlight any keyword, press F1, and Access will give you some information.
Once you understand the code, the answer to your question will be so obvious that you will be saying Doh!!!
Hint: look for the name of your Client listbox, you would handle the employee listbox the same way.
Here's my code for querying on the listclient box:
Private Sub cmdRunQuery_Cli ck()
On Error GoTo Err_cmdRunQuery _Click
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strWhere As String
Dim i As Integer
Set db = CurrentDb
'*** create the query based on the information on the form
strSQL = "SELECT
datetest1_tbl.f ld_year,datetes t1_tbl.fld_day, datetest1
_tbl.fld_
month,datetest1 _tbl.fld_break_ mins,datetest1
_tbl.fld_break _hrs,
datetest1_tbl.f ld_date,datetes t1_tbl.fld_clie nt,datetest1
_tbl.f
ld_project,date test1_tbl.fld_s ubproject,datet est1
_tbl.fld_cur re
ncy,
datetest1_tbl.f ld_duration_hrs ,datetest1
_tbl.fld_durat ion_mins,
datetest1_tbl.f ld_note, datetest1_tbl.f ld_rate,
datetest1_tbl.f ld_amount FROM datetest1_tbl "
strWhere = "Where ((datetest1_tbl .fld_date) Between
Forms!aspdash_f orm!date1 And Forms!aspdash_f orm!date2) and
datetest1_tbl.f ld_client IN ("
For i = 0 To listclient.List Count - 1
If listclient.Sele cted(i) Then
strWhere = strWhere & "'" & listclient.Colu mn(0, i)
& "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
strSQL = strSQL & strWhere
MsgBox strSQL
'*** delete the previous query
db.QueryDefs.de lete "qryMyQuery "
Set qdf = db.CreateQueryD ef("qryMyQuery" , strSQL)
'*** open the query
'*** DoCmd.OpenQuery "qryMyQuery ", acNormal, acEdit
Exit_cmdRunQuer y_Click:
Exit Sub
Err_cmdRunQuery _Click:
If Err.Number = 3265 Then '*** if the error is the
query is
missing
Resume Next '*** then skip the delete
line and
resume on the next line
Else
MsgBox Err.Description '*** write out the
error and exit
the sub
Resume Exit_cmdRunQuer y_Click
End If
End Sub
-- Bob Quintal
PA is y I've altered my email address.
-- Posted via a free Usenet account from http://www.teranews.com
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve |
last post by:
I'm trying to do a multi table query that displays all the info I need
in one array, and I'm having problems figuring out how to do it.
The two tables are product and vendor. A vendor can be a manufacturer,
distributor, or both. This is indicated via the manufacturer_YN and
distributor_YN fields in the vendor table, and vendor_id is an
auto_number field. In the product table, there is a manufacturer_id and
a distributor_id field, and...
|
by: kiqyou_vf |
last post by:
Hello all, I'm trying to figure out how to search a "key_words" column,
that contain key words (obviously) for that row. An example of what one
of the key_words contains is: "home interior decorating". I can search
for "home interior" or "interior decorating" and it will return the
correct row, but if I search for "interior home" or "home decorating" I
get nothing. I need it to return any row with ALL of those words in any
order. I am...
|
by: Ellen Ricca |
last post by:
I have an Access db with several ODBC linked ORACLE tables. These
tables have multiple-field PK's. The tables work just fine in many
diff types of queries including unmatched queries that are created
manually without using the UMQ Wizard. The problem/question, however,
involves using these tables in an UMQ Wizard. At the point in the
wizard where it asks for "What piece of information is in both
tables?" and it lists the fields from the 2...
|
by: Andy_Khosravi |
last post by:
I'm trying to build a search utility for users to find 'inquiries' in
my database that involves several tables. This is normally easy to do
with the query builder, but I have a unique situation involving a multi
select listbox. Unfortunatly, my SQL skills are somewhat limited, so
I'm not sure if there is an easy way around it. To simplify the
explanation, I'll simplify the table/field setup to get at the meat of
the question.
I have a...
|
by: abhishekjethwani |
last post by:
How to write a query to access tree structure form multi table. I m having five tables from them first table give me a data which act as the parameter for query for the second table and the two tables will give me parameter for the third and so on.
at present i m writing five query and sending parameter to each query but i want an efficient way for this.
its a parent child type relation.
| |
by: Stan |
last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can
I run a query of a query datasheet. I want to use more that one
criteria and can not get that query to work. I thought I might be
able to accomplish the results in two steps by using two queries. If
this is possible how can I do it?
Thank you,
Stan Hanna
|
by: mskapek |
last post by:
I need some advise on how to best create an Access 2002 report from multiple "total" queries, each which result in 3- 5 values that I need displayed on my report. Most of the queries do simple counts based on 3 different tables. For instance, I need to count the number of new clients enrolled in a program for a given month or year-to-date grouped by 4 different referral sources (based on the start date for the client). Then I need to count...
|
by: IAuditor |
last post by:
Access 2003, XP - I have a multi-table query that is losing data. 1 table is a lookup (Hierarchy), and the other 3 are virtual duplicates (all with a one-to-many relationship with the lookup) except for some field names. The Hierarchy field is identically named in all 3 tables. The query starts with the Hierarchy number, then descriptions, etc. Next are 2 long-integer fields that are used to calculate a Difference and %ofDifference fields. Up...
|
by: pedalpete |
last post by:
I know this doesn't sound right as how can php be different in safari vs ie/ff, but i've been updating a genre list on my page to a tag cloud.
When submitting the form using ie/ff the tag is sent properly, and the response is correct.
When submitting from safari or chrome, the tag is sent properly (i've left the alert in place), and you can see that the variable is recieved in php properly, but then the query returns no results.
This...
|
by: existential.philosophy |
last post by:
This is a new problem for me: I have some queries that open very
slowly in design view.
My benchmark query takes about 20 minutes to open in design view. That
same query takes about 20 minutes to open in datasheet view. As an
experiment, I deleted all rows in all tables; after that, the query
took only seconds to open in both design view and datasheet view. From
these facts, I conclude that Access is evaluating the query when I go
to...
|
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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: 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: 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...
| |