View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Bringing Data From Access To Excel

Someone else may have an easier way, but if I were doing it, I'd use VBA Code
and set up a Tools | References reference to the Access object library, then
in the code I'd create an instance of Access and set it to the database file,
create a recordset object to receive the results of an SQL statement that
would be built in the VBA code and executed against the database using the
Contract Number that had been entered, then simply transfer the data
retrieved into the Excel worksheet.

You can 'cheat' a little and use Access itself to create a query that would
retrieve the data you need based on a specific contract number and examine
the query in SQL View. That gives you a 'template' for the SQL string to be
built in your Excel VBA code. Lets say your SQL view of the query in Access
shows this:
SELECT tblContracts.* FROM tblContracts WHERE
(((tblContracts.ContractNumber) = 'ABC 24165'));

Then you could build a string in VB code as
strSQL = "SELECT tblContracts.* FROM tblContracts WHERE
(((tblContracts.ContractNumber) = '" & strContractNumber & "'));"

where strContractNumber contains the contract number from your Excel sheet.

Is that enough of a start, or do you need more detail?

SELECT tbl_Addresses.*
FROM tbl_Addresses
WHERE (((tbl_Addresses.Address_ID)=124));

"Alistaire Green" wrote:

I have a Task which id like you to ponder and see if any of you know how to
accomplish it.

As we know whilst in Excel we can lookup information from another sheet or
Wookbook by using the Vlookup or Hlookup functions.

The task i have been given is to get data from an access database into a
excel document in the kinda way we do with Vlookup etc.

For Example, We input a Contract Number into a Cell and then the rest of the
information regarding that contract is automatically bought from an access
database to the excel document.