Bug #1876 MyODBC 3.51.06 Bug
Submitted: 18 Nov 2003 10:48 Modified: 28 Nov 2003 9:48
Reporter: Justin Kent Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.06 OS:Windows (Windows XP Home/Pro)
Assigned to: CPU Architecture:Any

[18 Nov 2003 10:48] Justin Kent
Description:
Hello.

Am writing a data access macro in MS Word VBA. Was using MyODBC v2.5 and upgraded. Since, then I have had the following problem.

It seems that within VBA and under the new driver, I cannot assign a RecordSet field to a variable, whilst inside an IF statement when a RecordSet is open. The following code outlines the problem.

-------------------------------------------------------------------------------
MySQL = "SELECT LetterContentLocation" & _
  " FROM dm_work_lettertemplates WHERE LetterCode='" & LetterCode & "';"
rs.Source = MySQL
rs.Open
If rs.Fields("LetterContentLocation") <> "" Then
LetterContentLocation = rs.Fields("LetterContentLocation")  'THIS IS IGNORED
Else
LetterContentLocation = "None"
End If
rs.Close
-------------------------------------------------------------------------------

In the above, where the rs.field is not NULL, the variable will not be assigned to LetterContentLocation. If that single assignment is put outside the IF statement, no problems.  I know this IF statement is running as I have tested that. There is a problem with accessing the data within the IF statement as the VB command ' Selection.TypeText rs.fields("LetterContentLocation") ' also does not work unless outside the IF statement.

More interestingly, in the following code.....

-------------------------------------------------------------------------------
    MySQL4 = "SELECT " & VarField & " AS VariableField FROM " & VarTable & " WHERE " & _
    "ClaimCode='" & rs.Fields("ClaimCode") & "' AND ClaimNumber='" & rs.Fields("ClaimNumber") & "';"
    qs.Source = MySQL4
    qs.Open

    If Len(qs.Fields("VariableField")) > 0 Then
    If VarDate = "Yes" Then
    DataForLetter = Day(qs.Fields("VariableField")) & "/" & Month(qs.Fields("VariableField")) & _
    "/" & Year(qs.Fields("VariableField"))           ' WILL GET ASSIGNED
    Else
    DataForLetter = qs.Fields("VariableField")       ' WILL BE IGNORED
    End If
    Else
    DataForLetter = "N/A"
    End If
    
    qs.Close
-------------------------------------------------------------------------------

... the DateForLetter will get assigned if the variable is proven to be a date, otherwise it is again ignored and not assigned. 

All the above code works perfectly ok under MyODBC 2.5, only on the update to the latest version has this bug arisen.

Thanks.

Justin Kent. 

How to repeat:
I don't know how to repeat. Set up a similar scenario I guess!

I am using MySql 4.0.16, I obviously have MyODBC 3.51.06 and am running MS MDAC 2.8 on a Windows XP Home system. 

MySql is residing on a Windows 2000 server.

Please contact if you require further information.
[28 Nov 2003 9:48] Dean Ellis
I cannot repeat this issue with MyODBC 3.51.06 and MDAC 2.7 or MDAC 2.8 using the basic code sample you have provided, in either VBA/Word or VB itself.

Unless there is something more substantial in the code which was not included in your example, I can only assume that whatever the problem may be, it is not the fault of MyODBC, as MyODBC itself of course does not care whether or not your code uses an IF statement.

Thank you
[1 Dec 2003 1:57] Justin Kent
Thank you for your response.

I understand that you cannot replicate the error. I have now loaded the same macros onto different operating systems and still the error occurs. 

I am therefore stumped! Literally, the only difference between the macros working and failing at the points outlined in my previous message is on which MyODBC driver I use. The v2.5 works fine but the v3.51 fails. 

I have rolled back to the previous driver and guess I will have to continue with that one. 

Justin Kent.