Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Search any part of an Access recordset from Excel

I have been desperately trying to figure this out and I'm stumped.
So
I'm turning to my fellow Google Groupers.

I have a macro enriched Excel file that calls/edits information in a
MS Access database. There are about 20 fields in the database. I'm
using ADODB connection/recordset codings to get/edit my information.
I know how to code a SEARCH string in order to find one field of
information, but not multiple fields.

For example, I manage a database of permits. A few of the fields in
my database are permit number (permit_num), County (county),
Applicant
(app), and Route Name (route_nam) - to name a few. If I wanted to
search for the permit_num, my SEARCH would call that permit number.
But what if the user didn't have a specific piece of information. I
have 7 counties I deal with. What if the user knew the permit was in
Richland county, but didn't know anything else. There could be 10
different permits for that county. Or, more specifically, what if
the
user only new it was Main St. There could be 50 different
possibilities.

If I go into the database myself, I can do an Edit, Find and type in
a
wild card name like "main", click Find and then scroll through the
possibilities. I want to be able to do this through a VBA macro. I
just don't know how to go about doing it in the most efficient way.

Already, I can populate a Form Box with just a list of the permit
numbers.
The user types in the permit number and that is my search string
variable
that Excel goes into Access and finds. I want to have a Form Box
where
the user can type any variable and have Excel search for that in any
field
in Access and return a list of possible results.

database name: Permit.Tracker
table name: permit_info
typical ADODB line:
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=Z:\COMMON FILES\Encroachment Permits
\Permit.Tracker\Database\Permit.Tracker.mdb;"
typical recordset search line looking for one piece of info:
str = "SELECT permit_num FROM permit_info WHERE county = '" & sCounty
& "'"
rs.Open str, cn, adOpenKeyset, adLockOptimistic

Any ideas? Anyone up for the challenge?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Search any part of an Access recordset from Excel

Your best bet would be a drop-down list of field names to choose from and a
text box for the user to enter a search term.
You'd need to determine the type of the field selected, and then construct
the query accordingly (quoted value if text, unquoted if numeric, etc).


Tim


"gab1972" wrote in message
...
I have been desperately trying to figure this out and I'm stumped.
So
I'm turning to my fellow Google Groupers.

I have a macro enriched Excel file that calls/edits information in a
MS Access database. There are about 20 fields in the database. I'm
using ADODB connection/recordset codings to get/edit my information.
I know how to code a SEARCH string in order to find one field of
information, but not multiple fields.

For example, I manage a database of permits. A few of the fields in
my database are permit number (permit_num), County (county),
Applicant
(app), and Route Name (route_nam) - to name a few. If I wanted to
search for the permit_num, my SEARCH would call that permit number.
But what if the user didn't have a specific piece of information. I
have 7 counties I deal with. What if the user knew the permit was in
Richland county, but didn't know anything else. There could be 10
different permits for that county. Or, more specifically, what if
the
user only new it was Main St. There could be 50 different
possibilities.

If I go into the database myself, I can do an Edit, Find and type in
a
wild card name like "main", click Find and then scroll through the
possibilities. I want to be able to do this through a VBA macro. I
just don't know how to go about doing it in the most efficient way.

Already, I can populate a Form Box with just a list of the permit
numbers.
The user types in the permit number and that is my search string
variable
that Excel goes into Access and finds. I want to have a Form Box
where
the user can type any variable and have Excel search for that in any
field
in Access and return a list of possible results.

database name: Permit.Tracker
table name: permit_info
typical ADODB line:
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=Z:\COMMON FILES\Encroachment Permits
\Permit.Tracker\Database\Permit.Tracker.mdb;"
typical recordset search line looking for one piece of info:
str = "SELECT permit_num FROM permit_info WHERE county = '" & sCounty
& "'"
rs.Open str, cn, adOpenKeyset, adLockOptimistic

Any ideas? Anyone up for the challenge?

Thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Access recordset to import to Excel using ADO Spike Excel Programming 5 February 9th 09 08:30 PM
Code for getting Access recordset into Excel Matt[_48_] Excel Programming 8 June 25th 07 03:49 AM
Access Recordset Rows to Excel Geoff[_11_] Excel Programming 1 May 25th 05 05:41 PM
How to populate Excel Range from Access RecordSet? deko[_2_] Excel Programming 6 February 27th 05 03:43 PM
Acquiring a single recordset from Access into Excel Humsel Excel Programming 2 September 1st 04 07:04 AM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"