X
Xin
Here is my problem. After each time I updated my Access record, I need my
Excel sheet to be updated as well. For example, I entered patient interview
date in Access form, my excel sheet cell (1,1) should have patientID uploaded
automatically. Then I go to next patient record, excel cell(2,1) should be
uploaded, so on so forth.
Since I am very new to Access coding, I don't know how to solve this
problem. Any help would be greatly appreciated.
The following is the code that I wrote, right now it just static update
cell(2,1), how to moveNext, I need your guidance.
Private Sub Sdate1_AfterUpdate()
If Me.sdate1.Value <> "" Then
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rstD As DAO.Recordset
Dim i As Integer
Set dbs = CurrentDb
'Open existing workbook
Set oExcel = CreateObject("Excel.Application")
'Select Case Forms!frm_project_health_link!metcode
Select Case Me.metcode
Case 421, 422, 443, 487
Set oBook = oExcel.Workbooks.Open _
("C:\RCT follow up\Access Database\Link Random Table.xls")
'Add data to cells of a worksheet
Set oSheet = oBook.Worksheets("Link therapist 421,422,443,487")
oSheet.Cells(2, 1).Value = Me.SubjID
'Save the Workbook and Quit Excel
oBook.Save
oExcel.Quit
End Select
End If
End Sub
Excel sheet to be updated as well. For example, I entered patient interview
date in Access form, my excel sheet cell (1,1) should have patientID uploaded
automatically. Then I go to next patient record, excel cell(2,1) should be
uploaded, so on so forth.
Since I am very new to Access coding, I don't know how to solve this
problem. Any help would be greatly appreciated.
The following is the code that I wrote, right now it just static update
cell(2,1), how to moveNext, I need your guidance.
Private Sub Sdate1_AfterUpdate()
If Me.sdate1.Value <> "" Then
Dim oExcel As Excel.Application
Dim oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rstD As DAO.Recordset
Dim i As Integer
Set dbs = CurrentDb
'Open existing workbook
Set oExcel = CreateObject("Excel.Application")
'Select Case Forms!frm_project_health_link!metcode
Select Case Me.metcode
Case 421, 422, 443, 487
Set oBook = oExcel.Workbooks.Open _
("C:\RCT follow up\Access Database\Link Random Table.xls")
'Add data to cells of a worksheet
Set oSheet = oBook.Worksheets("Link therapist 421,422,443,487")
oSheet.Cells(2, 1).Value = Me.SubjID
'Save the Workbook and Quit Excel
oBook.Save
oExcel.Quit
End Select
End If
End Sub