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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From AccessForm to Excel

Status
Not open for further replies.

MuskyMan

Technical User
Jul 31, 2002
36
US
Could not get help on the office forum nor did I find FAQs to assist me.

Need to carry over 3 textbox.text from an access form to sheet1 in a workbook. I can get the workbook open when the user leaves the last textbox on the form but I get errors when trying to put the text in the sheet.

Thanks in advance for any input you may have.

 
Hard to tell what you are doing, but this simplified code updates three cells of a closed worksheet. Start with the worksheet closed. If you need it to work with the worksheet already open, then more code will be required.
Code:
Option Compare Database
Option Explicit
Sub demo()
  UpdateThreeCells "A", "B", "C"
End Sub
Sub UpdateThreeCells(Val1 As String, Val2 As String, Val3 As String)
Dim xl As Excel.Application
  Set xl = New Excel.Application
  xl.Workbooks.Open "C:\test.xls"
  xl.Cells(2, 3) = Val1
  xl.Cells(2, 4) = Val2
  xl.Cells(2, 5) = Val3
  xl.ActiveWorkbook.Save
  xl.ActiveWorkbook.Close
  Set xl = Nothing
End Sub
You should be able to use something like this:
Code:
  UpdateThreeCells Text1.Text, Text2.Text, Text3.Text


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top