Hi!
I'm hoping someone can help me get started on a form button I need to build in Access 2002.
I'm revamping an old database that uses alot of code and I`m not that hot on Access so here is what I need to do if someone can give me some tips on how to get started...
1) Take a postcode from a text box and query it against an Oracle linked table
2) Return all the addresses from that postcode in a form, listed by rows
3) When one of the rows is clicked information from the postcode autofills most of the boxes on my existing form (such as House No, Street, Town etc), closing down the results form in the process.
I can get by using queries I have build before in Access but I haven't got much experience on SQL so any help you could give would be great.
Thanks
Neil
6 1271
Hi!
I'm hoping someone can help me get started on a form button I need to build in Access 2002.
I'm revamping an old database that uses alot of code and I`m not that hot on Access so here is what I need to do if someone can give me some tips on how to get started...
1) Take a postcode from a text box and query it against an Oracle linked table
2) Return all the addresses from that postcode in a form, listed by rows
3) When one of the rows is clicked information from the postcode autofills most of the boxes on my existing form (such as House No, Street, Town etc), closing down the results form in the process.
I can get by using queries I have build before in Access but I haven't got much experience on SQL so any help you could give would be great.
Thanks
Neil
I'm not too sure about Oracle, but I successfully ran the following code against a ODBC, Linked SQL Server Table (Employees Table in the Northwind Database). I created an ADO Recordset on the Employees Table based on the value entered in the [City] Field and returned Addresses for those Cities. I then set the Recordset property of the Form to this Recordset assuming the Form was in Continuous View and had a Field previously Bound to Address. Let me know if you have any questions. -
Dim strSQL As String
-
Dim rstTest As New ADODB.Recordset
-
-
-
-
If Not IsNull(Me![City]) Then
-
strSQL = "Select * From dbo_Employees Where [City] = '" & Me![City] & "';"
-
With rstTest
-
.Source = strSQL
-
.ActiveConnection = CurrentProject.Connection
-
.CursorType = adOpenStatic
-
.LockType = adLockOptimistic
-
.Open
-
.MoveLast
-
.MoveFirst
-
End With
-
-
Do While Not rstTest.EOF
-
MsgBox rstTest![Address]
-
rstTest.MoveNext
-
Loop
-
Else
-
Exit Sub
-
End If
-
-
'Set the Form's Recordset to the ADO Recordset
-
Set Me.Recordset = rstTest
-
-
'Should not Close this Recordset in this Scope
-
'rstTest.Close
-
'Set rstTest = Nothing
Thats great - I'll give it a go and let you know how I get on!
Cheers
Neil
Thats great - I'll give it a go and let you know how I get on!
Cheers
Neil
Hey Neil,
Since I work with Oracle every day, I have another suggestion. It is simular, but it allows to work with Oracle Directly, and not have to go through an ODBC connecter, They are very slow, and this option gives you a better performance hit than going through ODBC.
Example: -
Sub GetAddress()
-
Dim cn As ADODB.Connection
-
Dim rs As ADODB.Recordset
-
-
Set cn = New ADODB.Connection
-
Set rs = New ADODB.Recordset
-
With cn 'This section allows you to directly connect using OLEDB to your oracle server.
-
'You will have to replace what I've put in Quotes with the actual names of these
-
'Values. If you're not sure what the values are, check with your IT Department.
-
.Provider = "MSDAORA"
-
.Properties("Data Source").Value = "Name of Oracle Server"
-
.Properties("User ID").Value = "Username"
-
.Properties("Password").Value = "Password"
-
.Open
-
End With
-
With rs
-
'This section connects you to the particular Oracle table that you're wanting
-
'to do the search against. Please note I used "CustomerList" as the name of the
-
'table. You will have to replace it with the actual name of the table.
-
'Also I'm assuming that you have a Control on your form that is named PostalCode
-
'This is what you're going to set the postalcode value from.
-
Set .ActiveConnection = cn
-
.Source = "SELECT * FROM CustomerList WHERE PostalCode = " & Me.Postalcode
-
.LockType = adLockReadOnly
-
.CursorType = adOpenKeyset
-
.CursorLocation = adUseClient
-
.Open
-
End With
-
'This Set Option is to set the recordset returned from Oracle and binds it to a list control
-
'that is on your form called ListControl. Replace that with the name of the list control on your
-
'form. Please note that the number of columns returned will have to be set in the List Control
-
'in order the information to return all the columns of data. By defualt the list control is set
-
'to 1, you'll need to change to the number of columns that you want to return from oracle.
-
-
Set Me.listcontrol.Recordset = rs
-
End Sub
-
'Now also keep in mind that I'm assuming that all the records in this table that you're pulling from
-
'also contains a Primary Key for Each entry in the able. if not, this example will not work.
-
Sub PullOneRecordInfo()
-
Dim cn As ADODB.Connection
-
Dim rs As ADODB.Recordset
-
-
Set cn = New ADODB.Connection
-
Set rs = New ADODB.Recordset
-
-
With cn
-
.Provider = "MSDAORA"
-
.Properties("Data Source").Value = "Name of Oracle Server"
-
.Properties("User ID").Value = "UserName"
-
.Properties("Password").Value = "Password"
-
.Open
-
End With
-
With rs
-
Set .ActiveConnection = cn
-
.Source = "SELECT * FROM CustomerList WHERE RecordID = " & Me.listcontrol.Value
-
.LockType = adLockReadOnly
-
.CursorType = adOpenKeyset
-
.CursorLocation = adUseClient
-
.Open
-
End With
-
-
If Not rs.EOF Then
-
Me.StreetNo = rs.Fields("FieldNameInTable") '<-- Replace FieldNameInTable with the actual
-
' field that stores that value
-
Me.City = rs.Fields("FieldNameInTable") '<-- Same Here
-
'and so on
-
End If
-
-
rs.Close '<-- A little House Keeping that needs to happen everytime you open a connection
-
cn.Close '<-- same here
-
-
Set rs = Nothing '<-- And Here
-
Set cn = Nothing '<-- and here also
-
-
Me.listcontrol.Requery
-
Me.Repaint
-
End Sub
-
Hope that helps a little. If you have any questions, please let me know.
Joe P.
Hello PianoMan64, it's nice to now know that we now have a resident Oracle Expert here in the Access Forum. We'll definately keep you in mind when Oracle/Access interface questions arise. I'll talk to Mary about giving you a raise in salary, but I wouldn't hold my breath on it. (LOL).
Hello PianoMan64, it's nice to now know that we now have a resident Oracle Expert here in the Access Forum. We'll definately keep you in mind when Oracle/Access interface questions arise. I'll talk to Mary about giving you a raise in salary, but I wouldn't hold my breath on it. (LOL).
Alright, thanks for the compliment.
Joe P.
Alright, thanks for the compliment.
Joe P.
Hi Joe,
Thanks very much - I`ll give it a go and let you know how I get on!
Cheers
Neil
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Daniel Tonks |
last post by:
First, please excuse the fact that I'm a complete MySQL newbie.
My site used forum software that I wrote myself (in Perl) which, up until
now, has used flat files. This worked fine, however...
|
by: Neil |
last post by:
I previously posted re. this, but thought I'd try again with a summary of
facts.
I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that
is linked to the database via ODBC...
|
by: smd |
last post by:
Hello and thanks for taking the time to read this. I've looked all
over the web and newsgroups and can't find a solution to my problem.
Since the source of the data is DB2, I figured I'd give you...
|
by: smd |
last post by:
Hello and thanks for taking the time to read this. I've looked all
over the web and newsgroups and can't find a solution to my problem.
I've posted this question to the Access 2000 group as well -...
|
by: ggk517 |
last post by:
We are trying to develop an Engineering application using PHP,
Javascript with Informix as the back-end.
Is it possible to retrieve data using Javascript but by accessing the
Database. Say...
|
by: Jimmy |
last post by:
ill have a database with 1 table and 3 fields:
ID FIRSTNAME LASTNAME
(the ID field will be the auto incrementing index)
there might be 10 records in the DB, there might be 10,000.
i...
|
by: Jim Devenish |
last post by:
I have a split front end/back end system. However I create a number of
local tables to carry out certain operations. There is a tendency for
the front end to bloat so I have set 'compact on...
|
by: kev |
last post by:
Hi all,
I have created a database for equipments. I have a form to register the
equipment meaning filling in all the particulars (ID, serial, type,
location etc). I have two buttons at the end...
|
by: jobrien9796 |
last post by:
I'm using Access 2002 with linked tables to access an SQL Server
database. Authentication is done using Windows authentication (not
user id+password). As far as I can tell, when the table is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |