Cdhirst
asked on
I need to export data from an access query into and premade excel document. i want the access data to specific cells in the excel doument.
I have a query which creates a form depending on what number I type in. I have created a button to export the data to excel. when I click this button I want it to export and fill the data into specific excel boxes of a premade excel document. how can I do this?
ASKER
i can show you the excel document if that would help ??
ASKER
The excel doc look like this.. My query creates a report that looks the same as this but i cant to convert the report/query into this excel doc
ASKER
here is the doc
Premade-excel.xlsx
Premade-excel.xlsx
what is the record source of the report?
copy and paste here.
copy and paste here.
ASKER
I think this is what you need?
L:\My Documents\Premade excel.xlsx
L:\My Documents\Premade excel.xlsx
ASKER
sorry I miss read
the record source from the report if found from running a query to find a specific record in a table
the record source from the report if found from running a query to find a specific record in a table
try these codes for a starter, continue the codes where i placed 'etc..
sub CopyToExcel()
dim xlObj as object, rs as DAO.recordset
set rs=currentdb.openrecordset ("NameOfQu ery")
if rs.eof then exit sub
set xlObj=createobject("excel. applicatio n")
xlObj.workbooks.open "L:\My Documents\Premade excel.xlsx"
with xlObj
.worksheets("sheet1").sele ct
.range("b2").value=rs!part number
.range("e2").value=rs!Rev
.range("b6").value=rs!part number
'.. etc....
.activeworkbook.save
end with
xlObj.quit
end sub
sub CopyToExcel()
dim xlObj as object, rs as DAO.recordset
set rs=currentdb.openrecordset
if rs.eof then exit sub
set xlObj=createobject("excel.
xlObj.workbooks.open "L:\My Documents\Premade excel.xlsx"
with xlObj
.worksheets("sheet1").sele
.range("b2").value=rs!part
.range("e2").value=rs!Rev
.range("b6").value=rs!part
'.. etc....
.activeworkbook.save
end with
xlObj.quit
end sub
ASKER
Here is the access database I have made
when u go to the switchboard click on 'ncm report' that will then open a box type in number 7605
this will then open a report. on the report I need a button that will send this report to excel in the format of the above excel document.
with the part number matching part number on the excel document and so on...
NCM-Data.accdb
when u go to the switchboard click on 'ncm report' that will then open a box type in number 7605
this will then open a report. on the report I need a button that will send this report to excel in the format of the above excel document.
with the part number matching part number on the excel document and so on...
NCM-Data.accdb
ASKER
I will try you code now quickly
ASKER
I couldn't get it to work I am not very experienced with VBA
post here, which field from the query goes to which cell in the excel file.
.
.
ASKER
ID from the query goes to NCM number
what about the other fields????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Part number goes to part number
Supplier goes to company..
I can probably work out how to get the rest in if I have a few code lines in..
I have left my computer for today and won't be back till Thursday.. Can't really match them up till I am back.
Is it possible to contact again on Thursday?
Supplier goes to company..
I can probably work out how to get the rest in if I have a few code lines in..
I have left my computer for today and won't be back till Thursday.. Can't really match them up till I am back.
Is it possible to contact again on Thursday?
ASKER
Thank I will check it out ASAP
ASKER
Thank you very much that worked really well
ASKER
Works really well thank you. Might have a few more problems but I will raise another question if I do
ASKER
HI
I have one more question about it. the company box in my report shows as text but when in exports to excel it shows up as a number. do you know how to change this as when it goes to excel I want it to show the company name not a number. when I tried it with your version it worked fine. cant understand why mine isn't
I have one more question about it. the company box in my report shows as text but when in exports to excel it shows up as a number. do you know how to change this as when it goes to excel I want it to show the company name not a number. when I tried it with your version it worked fine. cant understand why mine isn't
did you look at the sample db i uploaded?
ASKER
yes I did I managed to solve it thank you.
I was woundering if you knew how to get access to close itself automatically after a period of inactivity?
I was woundering if you knew how to get access to close itself automatically after a period of inactivity?
see the sample codes from Using Automation to Transfer Data to Microsoft Excel