madelca100
MIS
All,
I'm trying to write a function to convert a YYYYMMDD date field to a real date. I would like to call the function and have it return a particular field as a date.
I already have a generic function that works (see below).
I want this one to be very specific and don't want to pass the name of the field to the function. Without judging whether this is good form or not I would like to know if (and how) it can be done.
This following function works when I pass it the YYYYMMDD field name (e.g., cvtYYYYMMDD2Date(date_of_claim):
Function cvtYYYYMMDD2Date(strDateField As Variant) As Variant
cvtYYYYMMDD2Date = DateValue(Mid(strDateField, 5, 2) _
& "/" & Mid(strDateField, 7, 2) & "/" & Mid(strDateField, 1, 4))
End Function
This next function does not work.
oracle table = claim
oracle field = date_of_claim
Function DoC2Date() As Variant
DoC2Date = DateValue(Mid(claim!date_of_claim, 5, 2) _
& "/" & Mid(claim!date_of_claim, 7, 2) _
& "/" & Mid(claim!date_of_claim, 1, 4))
End Function
Error message:
Run-time error '424'
Object required
Can I even refer to the database directly?
If so, what am I missing?
btw - In case you haven't guessed it, I'm not a VBA programmer.
thanks,
mike
I haven't failed, I just found 10,000 ways that don't work.
I'm trying to write a function to convert a YYYYMMDD date field to a real date. I would like to call the function and have it return a particular field as a date.
I already have a generic function that works (see below).
I want this one to be very specific and don't want to pass the name of the field to the function. Without judging whether this is good form or not I would like to know if (and how) it can be done.
This following function works when I pass it the YYYYMMDD field name (e.g., cvtYYYYMMDD2Date(date_of_claim):
Function cvtYYYYMMDD2Date(strDateField As Variant) As Variant
cvtYYYYMMDD2Date = DateValue(Mid(strDateField, 5, 2) _
& "/" & Mid(strDateField, 7, 2) & "/" & Mid(strDateField, 1, 4))
End Function
This next function does not work.
oracle table = claim
oracle field = date_of_claim
Function DoC2Date() As Variant
DoC2Date = DateValue(Mid(claim!date_of_claim, 5, 2) _
& "/" & Mid(claim!date_of_claim, 7, 2) _
& "/" & Mid(claim!date_of_claim, 1, 4))
End Function
Error message:
Run-time error '424'
Object required
Can I even refer to the database directly?
If so, what am I missing?
btw - In case you haven't guessed it, I'm not a VBA programmer.
thanks,
mike
I haven't failed, I just found 10,000 ways that don't work.