I have an adodc control that is build with several tables using the select command. I need to search for a record on the adodc, is it possibles? If yes, how?
4 1966
Without seeing your code it is difficult to reply.
However in general there are two methods to do this.
The first is to include a WHERE clause in the ADODC select statement that only causes it to select the records you want. You can do this programatically by buiding the SQL code and then setting the ADODC command to it. This an example of buiding the SQL given that you have two tables, TableA and TableB joined on a field 'RELATED' and TableA has a field called 'COLOR' containing the value you want to look for.
[code]
dim SQL as string
dim Col as string
Col = inputbox("Enter the color you want to find")
SQL = "Select * from TableA inner join TableB on TableA.RELATED = TableB.RELATED "
SQL = SQL & "WHERE TableA.COLOR = '" & Col & "' "
[code]
in this code the variable SQL will contain the select statement that you can set in your ADODC control to return a specific recordset. Note the use of single & double quotes in the code when building the SQL statement
The other technique is to open the recordset and then use the SEEK method on the recordset. However this is cumbersome as you have to retrieve a full table and then search through it
Thank you very much, I have done that but am stuck on how to connect the sql to the adodc for it to open it.I didnt code my Adodc, so am not familiar with coding it.
this is the code i need to connect to my adodc1 -
-
DSearch = "SELECT DISTINCT H_DUTY_PER.H_DUTY_PER_ISST, H_DUTY_PER.H_DUTY_PER_EXPT, H_PER.H_PER_ISST, H_PER.H_PER_EXPT, INS_CERT.INS_CERT_ISST, INS_CERT.INS_CERT_EXPT, MOB_ADV.MOB_ADV_ISST, MOB_ADV.MOB_ADV_EXPT, RD_WORTH.RD_WORTH_ISST, RD_WORTH.RD_WORTH_EXPT, VEH_DESCRIPTION.VEHICLE_NO, VEH_DESCRIPTION.ENGINE_NO, VEH_DESCRIPTION.CHASIS_NO, VEH_LIC.VEH_LIC_ISST, VEH_LIC.VEH_LIC_EXPT, VEH_TYPE.VEHICLE_TYPE From H_DUTY_PER, H_PER, INS_CERT, MOB_ADV, RD_WORTH, VEH_DESCRIPTION, VEH_LIC, VEH_TYPE WHERE VEH_DESCRIPTION.VEHICLE_ID=VEH_TYPE.VEHICLE_ID And VEH_DESCRIPTION.VEHICLE_NO=VEH_LIC.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=H_DUTY_PER.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=H_PER.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=INS_CERT.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=MOB_ADV.VEHICLE_NO AND VEH_DESCRIPTION.VEHICLE_NO=RD_WORTH.VEHICLE_NO"
-
DSearch = DSearch & " WHERE VEH_DESCRIPTION.VEHICLE_NO = '" & VehNo & "'"
-
I have made the code better for your understanding below -
-
DSearch = "SELECT DISTINCT H_DUTY_PER.H_DUTY_PER_ISST,
-
H_DUTY_PER.H_DUTY_PER_EXPT, H_PER.H_PER_ISST,
-
H_PER.H_PER_EXPT, INS_CERT.INS_CERT_ISST,
-
INS_CERT.INS_CERT_EXPT, MOB_ADV.MOB_ADV_ISST,
-
MOB_ADV.MOB_ADV_EXPT, RD_WORTH.RD_WORTH_ISST,
-
RD_WORTH.RD_WORTH_EXPT, VEH_DESCRIPTION.VEHICLE_NO,
-
VEH_DESCRIPTION.ENGINE_NO, VEH_DESCRIPTION.CHASIS_NO, VEH_LIC.VEH_LIC_ISST, VEH_LIC.VEH_LIC_EXPT,
-
VEH_TYPE.VEHICLE_TYPE From H_DUTY_PER, H_PER, INS_CERT,
-
MOB_ADV, RD_WORTH, VEH_DESCRIPTION, VEH_LIC, VEH_TYPE
-
WHERE VEH_DESCRIPTION.VEHICLE_ID=VEH_TYPE.VEHICLE_ID And VEH_DESCRIPTION.VEHICLE_NO=VEH_LIC.VEHICLE_NO AND
-
VEH_DESCRIPTION.VEHICLE_NO=H_DUTY_PER.VEHICLE_NO AND
-
VEH_DESCRIPTION.VEHICLE_NO=H_PER.VEHICLE_NO AND
-
VEH_DESCRIPTION.VEHICLE_NO=INS_CERT.VEHICLE_NO AND
-
VEH_DESCRIPTION.VEHICLE_NO=MOB_ADV.VEHICLE_NO AND
-
VEH_DESCRIPTION.VEHICLE_NO=RD_WORTH.VEHICLE_NO"
-
DSearch = DSearch & " WHERE VEH_DESCRIPTION.VEHICLE_NO = '" & VehNo & "'"
-
The type of code you need to retrieve records using ADODB data objects is as follows -
-
Dim Conn as ADODB.connection
-
Dim Rs as ADODB.Recordset
-
DIim SQL as string
-
conn.connectstring = "The string needed to connect to your database"
-
conn.connect
-
-
' put the code to build your SQL string in the variable SQL here
-
-
rs.open SQL,conn,adopendynamic
-
if rs.bof = true then
-
'Put your code for handling no records returned here
-
end if
-
-
rs.movefirst
-
-
' Put your code for handling a record here. Fields in the record are referencedwith the syntax rs!Fieldname
-
-
-
use the vb help to look up the syntax & examples for ADODB.Connectio n and ADODB.Recordset objects
good luck
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: noah |
last post by:
Does PHP have a feature to associate Cookie sessions with a persistent
database connection that will allow a single transaction across
multiple HTTP requests?
Here is how I imagine my process: I have an series of interactive HTML
forms. The user begins a Cookie session. A database connection is
opened and a transaction is begun. After the user goes through any
number of pages where they update the database they finish on a page
where...
|
by: Patrick |
last post by:
I'm working on a contact management application, and need a hand with one
aspect...
Here's what I want to create:
------------------------------------
A form split into two parts. There is a datagrid on the left side that lists
names and perhaps a couple of other key fields. The user can click on a
record in the datagrid, which should automatically pull up details on that
record in the various text boxes and other controls on the right...
|
by: Mourad |
last post by:
Hi All,
Is it possible to create a Make Table query in access (2.0 and 2003)
that creates the table into a SQL Server database?
Following the steps:
1- Create New Query
2- Set Query Type as Make-Table query
3- Enter table name
4- Click "Another Database", click Browse, then I cannot see anything
|
by: psyvanz |
last post by:
Im a college student, my program is a computerized enrollment system, Im using MS ACCESS database in connecting my VB6 program form. Inside i'd created two tables, named "tbstudentinfo" and "tbstudentfees". In my 1st table i renamed my fieldname to STUDENTNUMBER and STUDENTNAME on the second fieldname, then below i entered (0001) for studnumber and (Paul) for studname. The 2nd table is almost the same with the 1st table but i added another...
|
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: 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: 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: 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: 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: 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...
| |