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

Excel Spreadsheet to Access Table 1

Status
Not open for further replies.

tful282

Programmer
Jun 26, 2001
42
US
I am looking for a way to update certain fields in an Access databse table from an Excel spreadsheet on a button-click. The spreadsheet was originally populated from the same database, then edited. Here are my main questions.

How can I specify the range of cells that should go into the recordset ? (can they be non-contiguous ?)
How do I put the text contents of Cells into RecordSet fields ?
How would I update the database table ?


VB is a new ballgame to me, so be gentle. thanks.
tful282
 
Well, i have managed to figure out my problem, and just in case anyone else is interested, here is my solution. Assume all variables have been declared.

Set WrkBk = Excel.ActiveWorkbook
Set WrkSht1 = WrkBk.Worksheets(1)
Set WrkSht2 = WrkBk.Worksheets(2)

DoCmd.OpenForm FormName:="FrmNm"
Set Frm = Forms("FrmNm")
Set RS = Frm.RecordsetClone

For i = 1 To 6 'For 6 recordsets
Set Rng = WrkSht2.Range("A" & i)
StrEmpty = ""
If Rng.Value = StrEmpty Then End
RS.FindFirst "Key = " & Rng
Frm.Bookmark = Frm.RecordsetClone.Bookmark
With RS
.Edit
!Fld1 = WrkSht1.Range("C5").Value
!Fld2= WrkSht1.Range("F" & (i + 9)).Value
!Fld3 = WrkSht1.Range("C6").Value
.Update
.Bookmark = .LastModified
End With
Next

I'm sure there is a more elegant solution out there. Well?
 
Hi tful282,

Seeing as no one else has bothered to thank you, I thought I should, as your example certainly deserves it.

So ...THANKS !!!

...Dale Watson dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top