Hello im trying to figure out a sql that if in the same table (tbl_ComponentP arts) and same record a number in the field (ComponentID) and text in the field (Part) are the same in another record in that table then count those records. Example: - ComponentID Part
-
1 test 2
-
36 test 13
-
1 test 2
-
1 test 1
The count would be 2 because two fields are the same.
6 1164 NeoPa 32,566
Recognized Expert Moderator MVP GROUP BY the two Fields in question then Count(*) .
Thanks NeoPA that works.... Now to use it in a VBA SQL how would my query SQL go? - SELECT tbl_ComponentParts.ComponentID, tbl_ComponentParts.Part, Count(*) AS UsedAlready
-
FROM tbl_ComponentParts
-
GROUP BY tbl_ComponentParts.ComponentID, tbl_ComponentParts.Part
-
HAVING (((Count(*))>1));
-
NeoPa 32,566
Recognized Expert Moderator MVP
I don't believe I understand the follow-on question.
Your SQL seems fine. No idea what VBA SQL could possibly refer to.
Im trying to figure out something what can be removed in the strSQL and how to do the same thing with a DCOUNT. -
Dim strSQL as integer
-
-
strSql = "SELECT tbl_ComponentParts.ComponentID, Count(*) AS UsedAlready " & vbCrLf & _
-
"FROM tbl_ComponentParts " & vbCrLf & _
-
"WHERE (((tbl_ComponentParts.ProductID)=[Forms]![frm_UpdateProductComponentsParts]![cboProduct])) " & vbCrLf & _
-
"GROUP BY tbl_ComponentParts.ComponentID " & vbCrLf & _
-
"HAVING (((Count(*))>1));"
-
-
If IsNull(strSQL) then
-
'do this
-
Else
-
'Do that
-
end if
-
Or convert the SQL into a DCount for a text box, how would that go? - =DCOUNT("*","tbl_ComponentParts","ProductID=" & [Forms]![frm_UpdateProductComponentsParts]![cboProduct] and something else?
twinnyfo 3,653
Recognized Expert Moderator Specialist
SoggyCashew,
I’m not sure I understand your question. I think you have your answer to the DCount() issue with your last bit of code. Just use all the criteria to need to count the specific records you are interested in. Since you are only using one table, that should be pretty straightforward .
NeoPa 32,566
Recognized Expert Moderator MVP SoggyCashew:
Im trying to figure out something what can be removed in the strSQL and how to do the same thing with a DCOUNT.
I'm afraid that makes absolutely no sense to me. I can't even make it into a recognisable sentence.
I think you're possibly assuming I must understand based on an understanding of what you're thinking about that isn't actually correct. Unfortunately though, I can't help until you express the actual situation clearly.
Something that may prove helpful to know is that the Domain functions require a Domain parameter (Second) that is not SQL. QueryDefs or simple tables are fine and it will take the name of either as a valid string value.
Otherwise I can't help until I understand what you're asking for.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: DataFreakFromUtah |
last post by:
Hello!
No question here, just a procedure for the archive.
Search critera:
count records imported count data imported count number of rows
imported
count number of records imported record import count automatically
import
and count records prompt for number of records imported import count
auto-import records
autoimport records count records before and after
|
by: Wilfried |
last post by:
Hi,
I have 5 tables:
main
data1
|
by: shaqattack1992-newsgroups |
last post by:
Hello Everyone,
At work, employees have been using a spreadsheet that I am trying to
import into an access database to make some reports. The problem I'm
having is that in the spreadsheet, they are storing the same type of
information in multiple cells. For example, for each machine in the
shop, there is a code for why the machine was down--A1, B1, C1...for
example. The spreadsheet is set up like this:
...
|
by: nehashri |
last post by:
hi
i am designing a database using Ms Access and ASP. i have 3 tables in access namely 'PERSONAL', other as 'POLICY' and 3rd one is named as 'STAFF'. in the contact table i have ID, Name, Children as fields. Also in policy table the firlds are:- ID, date_of_policy, no_policy, amount_paid, amount_balance and similarly the 3rd ie., staff has few fields. all three are linked my a common field which is ID
all i want is when the user searches...
|
by: Studiotyphoon |
last post by:
Hi,
I have report which I need to print 3 times, but would like to have
the following headings
Customer Copy - Print 1
Accounts Copy - Print 2
File Copy -Print 3
I created a macro to print the report three times, but do not know how
| |
by: Gareth Jones |
last post by:
Hi all,
I am attmepting to run a query based on 2 tables.
In the query there are 3 fields from table 1 and 2 fields from table 2.
The common field in both is Change.ID
The query is working however there is about 70% of the data missing from the 2 fields in table 2
|
by: Adam Adams |
last post by:
Hai
I need some help, for the record I am new to VB and access
I have two tables (parent) and (child) . I want to count the number of children for each parent. I want to use date of birth and not ChildID. The number must be returned to table (parent) field amount
This must be very simple
|
by: achikeziey |
last post by:
select mobile ,count(id) from
(select mobile ,id from phone_1204 where astatus='newsub' and left(service,4)='euro'
union all
select mobile,id from phone_1205 where astatus='newsub' and left(service,4)='euro' )
group by mobile
are this the right code
|
by: DesignsOnline |
last post by:
I have a table with many different fields in, including 40 separate image fields. ("Pic1" "Pic2" "Pic3" etc...)
each field has a single value (an image name) in, I need to be able to select all these fields as a single record and loop through them.
Something like Select Pic1, Pic2, Pic3, Pic4, etc... From Gallery Where GalleryID = 123
Each gallery has a unique id in the table and has several different fields including a couple of text...
|
by: isantiago926 |
last post by:
I'd like to know ho I can compute a count of the same names or codes between different fields.
For example, I have 4 fields each with different region names.
I'd like to have a field counting all equal occurrences comparing all fields.
If f1="X",f2="X",f3="X",f4="X"
then CountField = 4
|
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: 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: 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: 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.
| | |