|
 |
access thread: Linking to Excel
Message #1 by "Michaela" <lanmbran@h...> on Fri, 12 Oct 2001 11:01:09
|
|
Hi,
I'm a complete novice at Access, and I'm actually finding it quite
difficult as I normally work on the web side of things.
I'd like to run a query on the data I have in Access but have the result
input into an excel worksheet (the data for the query will come from the
same worksheet.)
eg:
A B C D
1 xyz abc ghi
2 rst jkl nop
Query would be select accountnumber from database where name like A1 then
insert result into B1. And so on for A2 and B2 etc.
Does this make sense?
At the moment I have a populated table in my database but I'm not sure
whether it is worth setting up a form or not.
Also, how could I set the query up so that if the information in the
database did not exactly match A1, it would find similar entries?
I know that I'm asking a lot, but I'd appreciate it, if people could just
recommend sources to go to, to help me accomplish these things. At the
moment I have Beginning Access 97 VBA Programming (which I find quite
difficult).
Cheers,
Michaela
Message #2 by "Phillip Johnson" <phillip.johnson@e...> on Tue, 16 Oct 2001 09:00:38
|
|
Michaela,
Either use the line of code on page 234 of your Beginning Access VBA (Try
It Out Number 2) and replace the query name and file path with your own.
Obviously the code shown is in a select statement so you should omit
the "Case 2" line from the start. Just create a form without a datasource
and place a button on with the code in the Click event.
Another way of doing this is to write code in Access that opens Excel,
then use Excel VBA to create a new spreadsheet and write the data in. You
could also change the appearance of the Excel spreadsheet using Excel VBA.
Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Excel VBA code will go here
On Error Resume Next
oApp.UserControl = True
If you are doing a lot of work like this, a book that I found useful was
the Wrox (Instant or Beginning, I cant remember which) Excel VBA book.
This will be also be useful if you want to query the data in Excel using
Access.
I also see that you have posted a request RE problems creating SQL in
Access. You say you are a beginner so I dont know if you know (you
probably do) that you can create a query in design view and then right
click on the title bar and select SQL view to "translate" your Access
query to SQL. To get a query to run from a field on your form you would
place "=[forms]![formName]![fieldName]" in the Criteria of that field in
your query.
Hope this helps
> Hi,
>
> I'm a complete novice at Access, and I'm actually finding it quite
> difficult as I normally work on the web side of things.
>
> I'd like to run a query on the data I have in Access but have the result
> input into an excel worksheet (the data for the query will come from the
> same worksheet.)
> eg:
> A B C D
> 1 xyz abc ghi
> 2 rst jkl nop
>
> Query would be select accountnumber from database where name like A1
then
> insert result into B1. And so on for A2 and B2 etc.
>
> Does this make sense?
>
> At the moment I have a populated table in my database but I'm not sure
> whether it is worth setting up a form or not.
>
> Also, how could I set the query up so that if the information in the
> database did not exactly match A1, it would find similar entries?
>
> I know that I'm asking a lot, but I'd appreciate it, if people could
just
> recommend sources to go to, to help me accomplish these things. At the
> moment I have Beginning Access 97 VBA Programming (which I find quite
> difficult).
>
> Cheers,
> Michaela
|
|
 |