Results 1 to 4 of 4
  1. #1
    toothpaste is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    9

    Displaying non ASCII characters in a recordset

    I have the following VB code:

    Code:
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rsFiltered As DAO.Recordset
    Dim strSQL As String
    Dim i As Integer
        
    strSQL = "SELECT " _
    & "DLookUp(" & Chr(34) & "'[first_name] & ' ' & [last_name]'" & Chr(34) & ",'[activeGuides]','[ID]=' & [activities].[guide]) AS guide," _
    & "activities.garden, " _
    & "activities.activityDate, " _
    & "activities.comment " _
    & "FROM activities; "
    
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset(strSQL)
        
        If Not rs.BOF And Not rs.EOF Then
            
            For i = LBound(myArray) To UBound(myArray)
                
                If myArray(i, 1) Then
                    rs.Filter = "[activities.activityDate]=" & myArray(i, 0)
                    
                    Set rsFiltered = rs.OpenRecordset
                    
                    Do While (Not rsFiltered.EOF)
                        
                        myArray(i, 2) = myArray(i, 2) & vbNewLine _
                        & rsFiltered!guide & " " _     <-- Buggy line
                        & rsFiltered!garden & " " _
                        & rsFiltered!activityDate & " " _
                        & rsFiltered!comment
                        
                        rsFiltered.MoveNext
                    Loop
                
                End If
            Next i
            
        End If
        
        rsFiltered.Close
        rs.Close
    
    
    Set rsFiltered = Nothing
    Set rs = Nothing
    Set db = Nothing
    the problem is that "rsFiltered!guide" contains unicode characters and causes the program to crash (removing the line works perfectly)
    Is there a way to extract the unicode data and display it in a textbox?



    Thanks!

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have this line:
    Code:
    For i = LBound(myArray) To UBound(myArray)
    Where is it declared?

    I think the error is caused by the DLookup function. It looks like there are too many single quotes/double quotes.

    Since you are looking up the first/last name in "activeguides" where activeguides.ID = activities.guide, is it possible to use a query with both tables in it? (are the tables linked?)

    Something like
    Code:
    SELECT
    [first_name] & ' ' & [last_name] AS Guide, 
    activities.garden, 
    activities.activityDate, 
    activities.comment 
    FROM activities Inner Join activeGuides On activities.guide = activeGuides.ID
    (this is as close as I can come without seeing the tables.....)

  3. #3
    toothpaste is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    9
    Thanks! it did fix it

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Great! I'll mark this solved......

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Converting a text string to its ASCII value
    By Access_Novice in forum Access
    Replies: 4
    Last Post: 03-19-2015, 10:28 PM
  2. Replies: 9
    Last Post: 02-11-2013, 03:09 PM
  3. Displaying an ADO Recordset in Immediate Window
    By desastrux in forum Programming
    Replies: 4
    Last Post: 12-14-2012, 03:47 PM
  4. Incorrect Binary-based ASCII sorting in tables
    By ajetrumpet in forum Programming
    Replies: 2
    Last Post: 11-24-2011, 06:00 PM
  5. OpenTextFile, unicode/ascii
    By dssrun in forum Programming
    Replies: 4
    Last Post: 11-23-2011, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums