dbTalk Databases Forums  

Data Type Mismatch - but not really.... ?

comp.databases.ms-access comp.databases.ms-access


Discuss Data Type Mismatch - but not really.... ? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
(PeteCresswell)
 
Posts: n/a

Default Data Type Mismatch - but not really.... ? - 01-18-2011 , 10:34 AM






The call to a routine has started throwing an Error 13-Data Type
Mismatch.

But it only accepts a date and a string - both of which really
are as advertised.

The only goofy thing I can find is that when I hit Shift+F2 in
the code window to jump to the called routine, Access throws
this: http://tinyurl.com/486rcv8 - which to indicate a missing
reference, except that the "reference" would be by the
application to itself.

Assuming that I'm not lying about the passed date really being a
date and the passed ref to the string really pointing to a
string, has anybody seen anything like this?

This routine has been working in the past - and is used daily in
production.... but not today.... -)


For the masochistically-inclined:

Couple screen snaps of Immediate window:
--------------------------------------------------
http://tinyurl.com/6yyhbbh
http://tinyurl.com/67zh6zo
-------------------------------------------------

The calling code (which throws the error at line 1021)
---------------------------------------------------
Private Sub txtPaymentDate_AfterUpdate()
1000 DebugStackPush Me.Name & ": txtPaymentDate_AfterUpdate"
1001 On Error GoTo txtPaymentDate_AfterUpdate_err

' PURPOSE: - To flag the date as custom
' - To determine if new date is business day
' - To notify parent that something has changed

1002 Dim S As String

1010 With DoCmd
1011 .Hourglass True
1012 .DoMenuItem acFormBar, acFile, acSaveRecord
1019 End With

1020 With Me
1021 .txtIsBizDay.Value = IsBizDay(.txtPaymentDate, S)
1022 .txtIsCustomPaymentDate.Value = True
1023 .Dirty = False
1029 End With

1030 With Me.Parent
1031 PaymentSchedule_ComputeAmounts Date, _
"ttblSecurity_PaymentAccrualDaily", _
"ttblSecurity_PaymentSchedule" 1032
..subResetSchedule.Form.Requery
1039 End With

1040 afterUpdateAllFields

1999 DoCmd.Hourglass False

txtPaymentDate_AfterUpdate_xit:
DebugStackPop
On Error Resume Next
Exit Sub

txtPaymentDate_AfterUpdate_err:
BugAlert True, "PaymentDate='" & Me.txtPaymentDate & "'."
Resume txtPaymentDate_AfterUpdate_xit
End Sub
---------------------------------------------------


The called routine
---------------------------------------------------
Public Function IsBizDay( _
ByVal theDate As Variant, _
ByRef theExplaination As String _
) As Boolean
1000 DebugStackPush mModuleName & ": IsBizDay"
1001 On Error GoTo IsBizDay_err

' PURPOSE: To determine whether-or-not a given date falls on a
normal
' business day in the context of banking holidays as
specified
' in tlkpHoliday and weekends
' ACCEPTS: - The date in question
' - Pointer to field to which we deliver a reason for
the
' date in question not being a business day
' RETURNS: True if the date in question does not fall on a
weekend
' or bank holiday, else False
'
1002 Dim myExplaination As String

1010 If IsWeekDay(theDate) = False Then
1011 myExplaination = Format$(theDate, "dddd")
1012 Else
1013 If IsHoliday(theDate, myExplaination) = False Then
1014 IsBizDay = True
1015 End If
1019 End If

1999 theExplaination = myExplaination

IsBizDay_xit:
DebugStackPop
On Error Resume Next
Exit Function

IsBizDay_err:
BugAlert True, ""
Resume IsBizDay_xit
End Function
---------------------------------------------------
--
PeteCresswell

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 11:27 AM






Well, aside from guessing that the error is occurring in the IsBizDay
function (not clear why you have a Variant argument there, rather than the
expected Date ...), I really can't tell any more. Can't you step through the
code to figure it out? Without knowing exactly what the input arguments
were, we haven't a chance in hell of determining the cause.

(PeteCresswell) wrote:
Quote:
The call to a routine has started throwing an Error 13-Data Type
Mismatch.

But it only accepts a date and a string - both of which really
are as advertised.

The only goofy thing I can find is that when I hit Shift+F2 in
the code window to jump to the called routine, Access throws
this: http://tinyurl.com/486rcv8 - which to indicate a missing
reference, except that the "reference" would be by the
application to itself.

Assuming that I'm not lying about the passed date really being a
date and the passed ref to the string really pointing to a
string, has anybody seen anything like this?

This routine has been working in the past - and is used daily in
production.... but not today.... -)


For the masochistically-inclined:

Couple screen snaps of Immediate window:
--------------------------------------------------
http://tinyurl.com/6yyhbbh
http://tinyurl.com/67zh6zo
-------------------------------------------------

The calling code (which throws the error at line 1021)
---------------------------------------------------
Private Sub txtPaymentDate_AfterUpdate()
1000 DebugStackPush Me.Name & ": txtPaymentDate_AfterUpdate"
1001 On Error GoTo txtPaymentDate_AfterUpdate_err

' PURPOSE: - To flag the date as custom
' - To determine if new date is business day
' - To notify parent that something has changed

1002 Dim S As String

1010 With DoCmd
1011 .Hourglass True
1012 .DoMenuItem acFormBar, acFile, acSaveRecord
1019 End With

1020 With Me
1021 .txtIsBizDay.Value = IsBizDay(.txtPaymentDate, S)
1022 .txtIsCustomPaymentDate.Value = True
1023 .Dirty = False
1029 End With

1030 With Me.Parent
1031 PaymentSchedule_ComputeAmounts Date, _
"ttblSecurity_PaymentAccrualDaily", _
"ttblSecurity_PaymentSchedule" 1032
.subResetSchedule.Form.Requery
1039 End With

1040 afterUpdateAllFields

1999 DoCmd.Hourglass False

txtPaymentDate_AfterUpdate_xit:
DebugStackPop
On Error Resume Next
Exit Sub

txtPaymentDate_AfterUpdate_err:
BugAlert True, "PaymentDate='" & Me.txtPaymentDate & "'."
Resume txtPaymentDate_AfterUpdate_xit
End Sub
---------------------------------------------------


The called routine
---------------------------------------------------
Public Function IsBizDay( _
ByVal theDate As Variant, _
ByRef theExplaination As String _
) As Boolean
1000 DebugStackPush mModuleName & ": IsBizDay"
1001 On Error GoTo IsBizDay_err

' PURPOSE: To determine whether-or-not a given date falls on a
normal
' business day in the context of banking holidays as
specified
' in tlkpHoliday and weekends
' ACCEPTS: - The date in question
' - Pointer to field to which we deliver a reason for
the
' date in question not being a business day
' RETURNS: True if the date in question does not fall on a
weekend
' or bank holiday, else False
'
1002 Dim myExplaination As String

1010 If IsWeekDay(theDate) = False Then
1011 myExplaination = Format$(theDate, "dddd")
1012 Else
1013 If IsHoliday(theDate, myExplaination) = False Then
1014 IsBizDay = True
1015 End If
1019 End If

1999 theExplaination = myExplaination

IsBizDay_xit:
DebugStackPop
On Error Resume Next
Exit Function

IsBizDay_err:
BugAlert True, ""
Resume IsBizDay_xit
End Function
---------------------------------------------------

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 11:51 AM



On 18/01/2011 17:27:53, "Bob Barrows" wrote:
Quote:
Well, aside from guessing that the error is occurring in the IsBizDay
function (not clear why you have a Variant argument there, rather than the
expected Date ...), I really can't tell any more. Can't you step through
the code to figure it out? Without knowing exactly what the input
arguments were, we haven't a chance in hell of determining the cause.

Questions and observations
1 TxtPaymentDate sounds more like a string than a date.
2 What data type does IsBizDay return - I would have guessed boolean.
3 Where you have typed ?IsBizDay(.txtpaymentdate,5) in the immediate window,
you don't appear to have got a result. 4 What type of data is txtIsBizDay? Is
it the same type of data as the function IsBizDay() returns?

Phil

Reply With Quote
  #4  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 12:00 PM



Per Bob Barrows:
Quote:
Well, aside from guessing that the error is occurring in the IsBizDay
function (not clear why you have a Variant argument there, rather than the
expected Date ...), I really can't tell any more. Can't you step through the
code to figure it out? Without knowing exactly what the input arguments
were, we haven't a chance in hell of determining the cause.
I should have emphasized the " Access throws
this: http://tinyurl.com/486rcv8 - which to indicate a missing
reference, except that the "reference" would be by the
application to itself." part.

I really don't think it's around typing bc the routine has worked
all these years.

That may sound hokey... but it seems to me like the "missing
reference" error trumps all. I suspect that once I explain/fix
that, the problem will go away.
--
PeteCresswell

Reply With Quote
  #5  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 12:02 PM



Per Phil:
Quote:
1 TxtPaymentDate sounds more like a string than a date.
It's a date. The 'txt' prefix refers to the control type within
the form. Also IsDate() confirms that it holds a date at the
time of the error.

Quote:
2 What data type does IsBizDay return - I would have guessed boolean.
Yes: Boolean

Quote:
3 Where you have typed ?IsBizDay(.txtpaymentdate,5) in the immediate window,
you don't appear to have got a result. 4 What type of data is txtIsBizDay? Is
it the same type of data as the function IsBizDay() returns?
The "5" is actually "S" - junk variable, of type "String".

The reason there is no result is that it trapped out.
--
PeteCresswell

Reply With Quote
  #6  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 12:08 PM



Per (PeteCresswell):
Quote:
This routine has been working in the past - and is used daily in
production.... but not today.... -)
FWIW, I'm putting my money on a corrupt form.

Reason: The Shift+F2 thing successfully jumps to the routine from
an Immediate window with the form not open.

But when I break the code with the form open, Shift+F2 throws the
"missing reference" error.

I'm gonna cross my fingers, export the form to ASCII, and then
rebuild it from the text file.
--
PeteCresswell

Reply With Quote
  #7  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 12:37 PM



Per (PeteCresswell):
Quote:
I'm gonna cross my fingers, export the form to ASCII, and then
rebuild it from the text file.
Nope..... SaveAsText ==> LoadFromText... same-old-same-old.

I think I'm back to the question of why Access throws this error:
http://tinyurl.com/486rcv8 when I Shift+F2 on IsBizDay() in the
code of the problem form - even just in design mode... yet it
does not throw the error and jumps to the routine as expected
when I Shift+F2 on IsBizDay() in an Immediate window... AND ....
Shift+F2 ALSO WORKS when IsBizDay() is referenced in code of a
dummy form that I created in the same application.

Sounds to me like I'm back to the corrupted form scenario - but
somehow SaveAsText ==> LoadFromText is not resolving the
corruption problem.

Doesn't sound possible to me. OTOH, I don't have a clue as to
the underlying processes.

--
PeteCresswell

Reply With Quote
  #8  
Old   
Salad
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 01:02 PM



(PeteCresswell) wrote:

Quote:
Per (PeteCresswell):

I'm gonna cross my fingers, export the form to ASCII, and then
rebuild it from the text file.


Nope..... SaveAsText ==> LoadFromText... same-old-same-old.

I think I'm back to the question of why Access throws this error:
http://tinyurl.com/486rcv8 when I Shift+F2 on IsBizDay() in the
code of the problem form - even just in design mode... yet it
does not throw the error and jumps to the routine as expected
when I Shift+F2 on IsBizDay() in an Immediate window... AND ....
Shift+F2 ALSO WORKS when IsBizDay() is referenced in code of a
dummy form that I created in the same application.

Sounds to me like I'm back to the corrupted form scenario - but
somehow SaveAsText ==> LoadFromText is not resolving the
corruption problem.

Doesn't sound possible to me. OTOH, I don't have a clue as to
the underlying processes.

What happens if you make a new form, CTRL-A/Cttl-C the objects from the
old form, paste into the new form, then copy the code for the old form
and paste into the new form?

Reply With Quote
  #9  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 01:10 PM



Per (PeteCresswell):
Quote:
I'm gonna cross my fingers, export the form to ASCII, and then
rebuild it from the text file.
Bingo.

The rebuild was working fine.... until I added the .RecordSource
as a query name - then the problem surfaced.

Seems like there is something about that query that's provoking
the problem.

Removed .RecordSource, assigned it in code when the form was
opened and/or flipped between "Edit" and "Browse" modes and it
seems tb working a-ok.

Go figure....
--
PeteCresswell

Reply With Quote
  #10  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Data Type Mismatch - but not really.... ? - 01-18-2011 , 02:28 PM



Per Salad:
Quote:
What happens if you make a new form, CTRL-A/Cttl-C the objects from the
old form, paste into the new form, then copy the code for the old form
and paste into the new form?
Bingo.

--
PeteCresswell

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.