Hi I am adapting my former colleagues VBA so when the VBA runs it firstly:
1)looks at the date in the access table and if this then matches the preset date in my excel worksheet (cells 1, Y..-refer to code below) it then places the value from the next field in my access table to a range of cells further down in my excel worksheet (cells 32,y..-refer to code below)
I keep getting a bunch of errors..currently "compile error: wrong number of properties or invalid property assignment"
I appreciate any help Pleassseee...Please find my code below..Thanks
I have also attached the excel worksheet where the the vba will be reading and matching the date and where it will be placing the value
Public Sub Report_Run23(LOCReport As Recordset, datasheet As Variant, RepType As Integer) 'OUTPATINETS FOLLOW-UP'
Dim AppExcel As Object
Dim CurrentPG As String
Dim CurrentSheet As Variant
Dim SPos As Integer
Dim rpos As Integer
Dim cpos As Integer
Dim overeight As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim x As Integer
Dim y As Integer
Dim count As Integer
Dim Test1 As Variant
Dim Test2 As Variant
Dim Test3 As Variant
Dim StartDate As Date
Dim EndDate As Date
Dim NewDate As Date
Dim SumTotal As Single
Dim PG As String
Dim Datasheet2 As Variant
' Start position of report data
rpos = 7
cpos = 2
' For 12 month reports
If RepType = 1 Then
End If
' Sets read start to begining of record
LOCReport.MoveFirst
' Counts number of fields in record
j = LOCReport.Fields.count
Select Case [Forms]![Test]![lstSpecialty]
Case "Cardiac Rehabilitation"
k = 37
End Select
Test1 = datasheet.Cells.Value(1, 3)
Test2 = LOCReport.Fields(1).Name
Test3 = LOCReport.Fields(2).Name
StartDate = [Forms]![Test]![txtStartDate]
StartDate = DateAdd("d", -364, EndDate)
' For 12 month reports
While Not LOCReport.EOF
For y = 3 To 14
If LOCReport.Fields(1).Value = datasheet.Cells.Value(1, y) Then
datasheet.Cells.Value(32, y) = LOCReport.Fields(2).Value
End If
'NewDate = DateAdd("m", y - 1, StartDate)
'datasheet.Cells(rpos, cpos + y).Value = DateAdd("m", i - 1, StartDate)
'datasheet.Cells(rpos, cpos + y).NumberFormat = "mmm-yy"
Next y
LOCReport.MoveNext
Wend
LOCReport.Close
End Sub
1)looks at the date in the access table and if this then matches the preset date in my excel worksheet (cells 1, Y..-refer to code below) it then places the value from the next field in my access table to a range of cells further down in my excel worksheet (cells 32,y..-refer to code below)
I keep getting a bunch of errors..currently "compile error: wrong number of properties or invalid property assignment"
I appreciate any help Pleassseee...Please find my code below..Thanks
I have also attached the excel worksheet where the the vba will be reading and matching the date and where it will be placing the value
Public Sub Report_Run23(LOCReport As Recordset, datasheet As Variant, RepType As Integer) 'OUTPATINETS FOLLOW-UP'
Dim AppExcel As Object
Dim CurrentPG As String
Dim CurrentSheet As Variant
Dim SPos As Integer
Dim rpos As Integer
Dim cpos As Integer
Dim overeight As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim x As Integer
Dim y As Integer
Dim count As Integer
Dim Test1 As Variant
Dim Test2 As Variant
Dim Test3 As Variant
Dim StartDate As Date
Dim EndDate As Date
Dim NewDate As Date
Dim SumTotal As Single
Dim PG As String
Dim Datasheet2 As Variant
' Start position of report data
rpos = 7
cpos = 2
' For 12 month reports
If RepType = 1 Then
End If
' Sets read start to begining of record
LOCReport.MoveFirst
' Counts number of fields in record
j = LOCReport.Fields.count
Select Case [Forms]![Test]![lstSpecialty]
Case "Cardiac Rehabilitation"
k = 37
End Select
Test1 = datasheet.Cells.Value(1, 3)
Test2 = LOCReport.Fields(1).Name
Test3 = LOCReport.Fields(2).Name
StartDate = [Forms]![Test]![txtStartDate]
StartDate = DateAdd("d", -364, EndDate)
' For 12 month reports
While Not LOCReport.EOF
For y = 3 To 14
If LOCReport.Fields(1).Value = datasheet.Cells.Value(1, y) Then
datasheet.Cells.Value(32, y) = LOCReport.Fields(2).Value
End If
'NewDate = DateAdd("m", y - 1, StartDate)
'datasheet.Cells(rpos, cpos + y).Value = DateAdd("m", i - 1, StartDate)
'datasheet.Cells(rpos, cpos + y).NumberFormat = "mmm-yy"
Next y
LOCReport.MoveNext
Wend
LOCReport.Close
End Sub
Attachments
Last edited: