Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access to Excel

Status
Not open for further replies.

PALman

Technical User
May 15, 2002
160
0
0
GB
Is it possible to insert a value into a cell in Excel which is dependant on a field value within an Access table?
If possible, I would like code for this to be placed in a control button on a Access Form.
Any help much appreciated.
 
Try putting something like this in your button's click event. I grabbed this from an application I made, and changed a few things so it would make sense. Change the names of things as you like.

Code:
Dim StatusSheet As New Excel.Workbook
    Set StatusSheet = GetObject("c:\sheets\MySheet.xls")
    StatusSheet.Sheets(1).Cells(2, 2)="MyVal"
    StatusSheet.Save
    StatusSheet.Close

I cut a bunch of stuff out and gave you just the basics. This should work. Note that Cells(x,y) gives you row,col references which is backward from the usual "C5" reference.
 
I almost forgot--You'll need a reference to Microsoft Excel objects for this to work.
 
Thanks Reuel,
I am sure this is just the coding I need but at present I am getting the error "User-Defined Type" Not Defined.
Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top