Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

2.0 dibblers-n-dabblers

For those (scant few?) of us that have taken a liking to maniuplating the .CTY directly, don't forget that it is now fully UniCode. Hence something like this VB code will be needed to deal with both V1 and V2 CTY files...

Getting from CTY:

        On Error Resume Next
        sArticle = GetStringFromOleField(rs!oleArticle)
        If Err.Number Then
            sArticle = StrConv(GetStringFromOleField(rs!sArticle), vbFromUnicode)
        End If
        On Error GoTo 0


Putting Back:

        On Error Resume Next
        GetOleFieldFromString rs!oleArticle, sArticle
        If Err.Number Then
            GetOleFieldFromString rs!sArticle, StrConv(sArticle, vbUnicode)
        End If
        On Error GoTo 0

The error trap catches the changed field name (oleArticle in V1, sArticle in V2), which works to tell us we need to do the UniCode switcharoo.

Hope this helps someone else avoid a few minutes head scratching ;-)

Tim Jones
Wednesday, May 07, 2003

You can also look at the sole record in tblVersion to determine whether you're dealing with a CD1 or CD2 file.

Mike Gunderloy
Wednesday, May 07, 2003

*  Recent Topics

*  Fog Creek Home