Hi
Just found this forum and expect to make good use of it.
I've some experience of Access, I've had fun with vba subforms and suchlike but in an old version of Access (2000) so if I need to use vba I'll be dipping in here for tips.
I've more experience with Excel, have coded vba extensively there (last project was 800 lines of code) so I've some understanding of vba generally.
What's giving me grief at the moment is trying to add calculations to queries based on columns in the query... it seems to randomly expect 'Expression' or 'Group by' as column types, and Im having to create 3 sets of queries following on from each other to de-dupe data and allow filters on calculated values.
Also I've got a function which turns a date into a quarterly cohort, e.g. Oct 2013 -> 20134. I use ot on a lot of dates. I created a VBA function, CohortQ used as follows in queries:
Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 CohortQ([InputDate]))
In the VBA, InputDate is defined as a date
But when I run it on a date field, it gives me a data mismatch error. I can't step through as it's working on 600K rows.
If I put the function into the query,
Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 Year([InputDate])*10+DatePart("q",[InputDate]))
it works.
Any ideas why?
Anyway. Hi!
The Grim North is the Grim North of the UK, where on the map there's no towns or anything, just a note saying 'Here Be Dragons'
Just found this forum and expect to make good use of it.
I've some experience of Access, I've had fun with vba subforms and suchlike but in an old version of Access (2000) so if I need to use vba I'll be dipping in here for tips.
I've more experience with Excel, have coded vba extensively there (last project was 800 lines of code) so I've some understanding of vba generally.
What's giving me grief at the moment is trying to add calculations to queries based on columns in the query... it seems to randomly expect 'Expression' or 'Group by' as column types, and Im having to create 3 sets of queries following on from each other to de-dupe data and allow filters on calculated values.
Also I've got a function which turns a date into a quarterly cohort, e.g. Oct 2013 -> 20134. I use ot on a lot of dates. I created a VBA function, CohortQ used as follows in queries:
Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 CohortQ([InputDate]))
In the VBA, InputDate is defined as a date
Code:
Function CohortQ(InputDate As Date) As Integer
If InputDate = 0 Then
CohortQ = 0
Exit Function
End If
If Year(InputDate) < 1990 Or Year(InputDate) > 2020 Then
CohortQ = 0
Exit Function
End If
On Error Resume Next
CohortQ = Year(InputDate) * 10 + DatePart("q", InputDate)
If Err.Number <> 0 Then
CohortQ = 0
Exit Function
End If
End Function
But when I run it on a date field, it gives me a data mismatch error. I can't step through as it's working on 600K rows.
If I put the function into the query,
Cohort: IIf Year([InputDate]) < 1990 or Year([InputDate]) > 2020, 0 Year([InputDate])*10+DatePart("q",[InputDate]))
it works.
Any ideas why?
Anyway. Hi!
The Grim North is the Grim North of the UK, where on the map there's no towns or anything, just a note saying 'Here Be Dragons'