Working in 32 bit but not in 64. (1 Viewer)

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
This code works like a champ in Office 365 Access 32/Windows 10.
It builds a string of tags in a memo field on the parent form and copies it to the clipboard.

Like #architecture #building #abandoned etc.

However in Access 64/Windows 11 it behaves erratically. It usually stops at 3 tags.

Any suggestions what might be the problem here?

All suggestions will be appreciated.

Code:
Public Sub GenerateList()
    On Error GoTo ErrorHandler

DoCmd.RunCommand acCmdSaveRecord
   
Forms![frmTaglist]![ST_String] = ""

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM qrySelected")

Dim MaxChar As Integer
MaxChar = DMax("Set_MaxChar", "tblSettings")

Dim TagSTR As String
Dim TempSTR As String

'Check to see if the recordset actually contains rows
If Not (rs.EOF And rs.BOF) Then
    rs.MoveFirst
    Do Until rs.EOF = True

    TagSTR = " #" & rs!Tag_Name
               
    Forms![frmTaglist]![ST_String] = Forms![frmTaglist]![ST_String] & TagSTR
   
    Forms![frmTaglist]![txtCharacters] = Len(Forms![frmTaglist]![ST_String])
   
   
    Forms![frmTaglist]![ST_String].SetFocus
    DoCmd.RunCommand acCmdCopy
   
     
    If Len(Forms![frmTaglist]![ST_String]) > MaxChar Then
        Forms![frmTaglist]![ST_String].ForeColor = vbRed
        Forms![frmTaglist]![txtCharacters].ForeColor = vbRed
           
        Else
       
        Forms![frmTaglist]![ST_String].ForeColor = vbBlack
        Forms![frmTaglist]![txtCharacters].ForeColor = vbBlack
       
        End If
       
       
       
    rs.MoveNext

    Loop
Else

    MsgBox "No tags have been selected yet! "


End If


rs.Close 'Close the recordset
Set rs = Nothing 'Clean up

Forms![frmTaglist]![ST_String].SetFocus
   DoCmd.RunCommand acCmdCopy
 
   Me.fldHidden.SetFocus

ExitHandler:
    Exit Sub

ErrorHandler:
    Select Case Err
    Case 0
        'MsgBox "Action cannot be completed! ", vbExclamation, ""
        Resume ExitHandler
    Case Else
        'MsgBox Err.Description, vbExclamation, "Error #: " & Err.Number
        Resume ExitHandler
    End Select
   
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:36
Joined
Oct 29, 2018
Messages
21,690
Temporarily disable your Error Handler and then step through the code, so you can see what the actual error message is.
 

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
Temporarily disable your Error Handler and then step through the code, so you can see what the actual error message is.
Thanks for the quick reply.

I get this error: RH-Tags (App Name) couldn't open the Clipboard.

I removed: DoCmd.RunCommand acCmdCopy and now it build the string just fine.
So now I need to figure out how copy the string to the Clipboard in 64 bit.
 
Last edited:

Mike Krailo

Well-known member
Local time
Today, 07:36
Joined
Mar 28, 2020
Messages
1,156
Your initial post makes this sound like some tags get copied and others do not. Have you tested with shorter length strings?
 

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
Your initial post makes this sound like some tags get copied and others do not. Have you tested with shorter length strings?
The tags are anywhere from 8 to 25 characters. It just stops at 3 tags, regardless of the length.
The string builds fine as long as I don't copy it to the clipboard.
 

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
Does that happen right away on the first record?
It stops at the 3rd tag.

Of course I can do away with copying it to the clipboard automatically and do it manually when all required tags have been selected and added to the string.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:36
Joined
Oct 29, 2018
Messages
21,690
The tags are anywhere from 8 to 25 characters. It just stops at 3 tags, regardless of the length.
The string builds fine as long as I don't copy it to the clipboard.
Perhaps try combining all the tags first before copying them to the clipboard? Just a thought...
 

Mike Krailo

Well-known member
Local time
Today, 07:36
Joined
Mar 28, 2020
Messages
1,156
Is the text selected at the time of the copy? If the actual text in the memo field is not selected, it won't copy to the clipboard. It also won't generate an error like you are getting either so that's probably not it, I'm just throwing that out there. The error is happening on the the DoCmd.RunCommand acCmdCopy line, but you have two such lines like that. Which one is it failing on?

It's going to be difficult to determine exactly what is going on without having a sample database to work with. I don't know how you determine what tags are selected. It's not clear why the tags need to be copied to the clipboard while the tag string is being built. Is the memo field bound/unbound? I would prefer to build a string using a variable and not inside of a form control, then populate the form control and the clipboard at the same time at the end.

Maybe there is a difference due to the code being compiled 32bit vise 64bit.
 
Last edited:

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
Is the text selected at the time of the copy? If the actual text in the memo field is not selected, it won't copy to the clipboard. It also won't generate an error like you are getting either so that's probably not it, I'm just throwing that out there. The error is happening on the the DoCmd.RunCommand acCmdCopy line, but you have two such lines like that. Which one is it failing on?
Failing on both, and yes, the the whole text is selected but only copies part of it.
 

Mike Krailo

Well-known member
Local time
Today, 07:36
Joined
Mar 28, 2020
Messages
1,156
I edited my last post to include more questions. I'm unable to duplicate any circumstance that would only partially copy the text in an unbound memo field. Suggest sample database.
 

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
Is the text selected at the time of the copy? If the actual text in the memo field is not selected, it won't copy to the clipboard. It also won't generate an error like you are getting either so that's probably not it, I'm just throwing that out there. The error is happening on the the DoCmd.RunCommand acCmdCopy line, but you have two such lines like that. Which one is it failing on?

It's going to be difficult to determine exactly what is going on without having a sample database to work with. I don't know how you determine what tags are selected. It's not clear why the tags need to be copied to the clipboard while the tag string is being built. Is the memo field bound/unbound? I would prefer to build a string using a variable and not inside of a form control, then populate the form control and the clipboard at the same time at the end.

Maybe there is a difference due to the code being compiled 32bit vise 64bit.
The memo field is bound and the reason I did it like that is so it shows the user all changes with every select and deselect. That part works well, it just doesn't want to copy to the clipboard like it does just fine in the 32 bit version.
 

Mike Krailo

Well-known member
Local time
Today, 07:36
Joined
Mar 28, 2020
Messages
1,156
What is the user selecting and deselecting? Is that a list box of items or checkboxes? You could try and decompile a copy of your database and recompile it as 64bit and see if it still has the same errors on the 64bit office version machine. Just for context, it would be nice to see the form in question that the user does the selecting and deselecting of tags. How many total tags are there?
 

KitaYama

Well-known member
Local time
Today, 20:36
Joined
Jan 6, 2022
Messages
1,658
it just doesn't want to copy to the clipboard like it does just fine in the 32 bit version.
I use the following code to copy long texts to clipboard in 64bit office.

SQL:
Function Clipboard(StoreText As String) As String

    'PURPOSE: Read/Write to Clipboard'
    'Source: ExcelHero.com (Daniel Ferry)'

    Dim txt As Variant

    'Store as variant for 64-bit VBA support'
    txt = StoreText

    'Create HTMLFile Object'
    With CreateObject("htmlfile")
        With .parentWindow.clipboardData
            Select Case True
                Case Len(StoreText)
                    'Write to the clipboard'
                    .setData "text", txt
                Case Else
                    'Read from the clipboard (no variable passed through)'
                    Clipboard = .GetData("text")
            End Select
        End With
    End With

End Function

First create your whole string, then pass it to clipboard;
Code:
MyString = "........"
MyString= Mystring & "......"
Clipboard MyString
 
Last edited:

Catalina

Registered User.
Local time
Today, 04:36
Joined
Feb 9, 2005
Messages
471
What is the user selecting and deselecting? Is that a list box of items or checkboxes? You could try and decompile a copy of your database and recompile it as 64bit and see if it still has the same errors on the 64bit office version machine. Just for context, it would be nice to see the form in question that the user does the selecting and deselecting of tags. How many total tags are there?

I think have found the solution on Devhut.

Save Content to the Clipboard

It works well on the 32 and 64 versions.

Thank you guys for trying to help me, I appreciate it.

Kitayama, I will try your code as well and let you know about the results.
 

Mike Krailo

Well-known member
Local time
Today, 07:36
Joined
Mar 28, 2020
Messages
1,156
Catalina, does that mean you are using the API to do the copy/paste and no longer have any errors?
 

Users who are viewing this thread

Top Bottom