krijg de melding "Cant open clipboard (foutcode 521)"

Status
Niet open voor verdere reacties.

mnemonic

Gebruiker
Lid geworden
25 mrt 2016
Berichten
114
Op een oude pc met Windows XP stond een factureer programmaatje wat geschreven is in Virtual basic 6.
Deze moest ik op een nieuwe pc zetten met Windows 10 erop.
Vele meldingen heb ik op kunnen lossen maar de volgende melding niet.

Cant open clipboard (foutcode 521)

Dit gebeurt bij dit blad als je produckten moet selecteren (plus aantal) voor een rekening.
TTLAccount.jpg
Na het invoeren van BV 1x boven prothese 1x boormal (implantaat)incl model gaat het nog goed maar bij de derde invoer geeft hij de melding en sluit deze het programma.
Als ik dan die weer opstart en het weer probeer geeft hij de melding al soms bij de eerste invoer.

Ik zat zelf te denken dat het klembord vol is of niet wordt overschreven of zoiets maar de oplossing kan ik hier nog niet voor vinden.
Ik hoop jullie wel.

Hieronder de code die bij dit blad hoort.

Code:
Private Sub cmdEinde_Click()

'leeghalen tekstvelden
TextA1.Text = ""
Text1.Text = ""
TextA2.Text = ""
Text2.Text = ""
TextA3.Text = ""
Text3.Text = ""
TextA4.Text = ""
Text4.Text = ""
TextA5.Text = ""
Text5.Text = ""
TextA6.Text = ""
Text6.Text = ""
TextA7.Text = ""
Text7.Text = ""
TextA8.Text = ""
Text8.Text = ""
TextA9.Text = ""
Text9.Text = ""
TextA10.Text = ""
Text10.Text = ""
    
    cmdZoeken1.Enabled = True
    cmdZoeken2.Enabled = True
    cmdZoeken3.Enabled = False
    cmdSelecteren.Enabled = False
    cmdPrintenBon.Enabled = False
    opdrachtbon.WindowState = 0
    opdrachtbon.Hide
    hoofdform_opdrachtbon.Show
    
End Sub

Private Sub cmdHoofdmenu_Click()
    opdrachtbon.Hide
    TTLAccount.Show
End Sub

Private Sub cmdPlaatsen_Click()
    SearchStr$ = comboNaam
    tandartsen.Recordset.Index = "Naam"
    tandartsen.Recordset.Seek "=", SearchStr$
    comboNaam.Clear
    comboNaam.Visible = False
    cmdPlaatsen.Visible = False
    cmdZoeken1.Enabled = False
    cmdZoeken2.Enabled = False
    cmdZoeken3.Enabled = True
End Sub

Private Sub cmdPrintenBon_Click()
Dim sql As String
Set db = OpenDatabase("c:\TTL Account\TTLAccount.mdb")
Dim s1 As Recordset
Dim s2 As Recordset
Dim s3 As Recordset
Dim aantal
Dim totaal
Dim o '= omschrijving
Dim a '= aantal
Dim p '= prijs
Dim t '= tandarts
Dim n '= nummer bon
Dim k '= kortingspercentage
    
    opdrachtbon.Hide
    evenwachten.Show

t = "t" & txtNummerTandarts.Text
n = txtNummerOpdrachtbon.Text
totaal = 0

notas.UpdateRecord

DoEvents
sql = "select * from notas where notanr = " & n & " "
Set s1 = db.OpenRecordset(sql, dbOpenSnapshot)
Do While Not s1.BOF And Not s1.EOF
    o = s1!artikel
    a = s1!aantal
    sql = "select * from artikel where Omschrijving = '" & o & "' "
    Set s2 = db.OpenRecordset(sql, dbOpenSnapshot)
        DoEvents
        p = s2!Prijs
    DoEvents
    sql = "select " & t & " from artikel where Omschrijving = '" & o & "' "
    Set s3 = db.OpenRecordset(sql, dbOpenSnapshot)
        DoEvents
        k = s3.Fields(t).Value
    If k = 0 Then
        bedr = p * a
    Else
        bedr = (p * a) / 100 * (100 - k)
    End If
    
    pp = Int(bedr * 100) / 100
    
    totaal = totaal + pp
'evt hier ook zonder korting uit laten rekenen

s1.MoveNext
Loop
    
db.Close

'vullen faktuur in mdb
    fakturen.Recordset.AddNew
    
    numt = txtNummerTandarts.Text
    txtTussen3.DataField = "num_tandarts"
    txtTussen3.Text = numt
    
    nmm = txtMaand.Text
    txtTussen4.DataField = "nm_maand"
    txtTussen4.Text = nmm
    
    nmp = txtNaamPatient.Text
    txtTussen5.DataField = "nm_patient"
    txtTussen5.Text = nmp
    
    notanum = txtNummerOpdrachtbon.Text
    txtTussen6.DataField = "notanum"
    txtTussen6.Text = notanum
    
    numb = txtNummerBon.Text
    txtTussen7.DataField = "num_bon"
    txtTussen7.Text = numb
    
    txtTussen8.DataField = "bedrag"
    txtTussen8.Text = totaal
    
    fakturen.Recordset.MoveLast
    
'leeghalen tekstvelden
TextA1.Text = ""
Text1.Text = ""
TextA2.Text = ""
Text2.Text = ""
TextA3.Text = ""
Text3.Text = ""
TextA4.Text = ""
Text4.Text = ""
TextA5.Text = ""
Text5.Text = ""
TextA6.Text = ""
Text6.Text = ""
TextA7.Text = ""
Text7.Text = ""
TextA8.Text = ""
Text8.Text = ""
TextA9.Text = ""
Text9.Text = ""
TextA10.Text = ""
Text10.Text = ""
    
'sluiten form
    cmdZoeken1.Enabled = True
    cmdZoeken2.Enabled = True
    cmdZoeken3.Enabled = False
    cmdSelecteren.Enabled = False
    cmdPrintenBon.Enabled = False
    opdrachtbon.WindowState = 0
    

'naar Word
    Dim WordObj As Object
    On Error GoTo maken
    Set WordObj = GetObject(, "Word.Application")
    WordObj.Documents.Open "c:\ttl account\opdrachtbon.doc"
    WordObj.Visible = False
    WordObj.Documents(1).SaveAs "c:\windows\temp\" & notanum & ""
    WordObj.application.Run MacroName:="vullen"
    WordObj.Documents(1).SaveAs "c:\ttl account\bonnen\" & notanum & " - " & nmp & " - " & nmm & ".doc"
    WordObj.Documents(1).Close

'    Dim objWordApp As Object
'    Set objWordApp = GetObject("", "Word.Application")
'    If objWordApp Is Nothing Then
'        Set objWordApp = CreateObject("Word.Application")
'    End If
'    objWordApp.Documents.Open "c:\ttl account\opdrachtbon.doc"
'    objWordApp.Visible = False
'    objWordApp.Documents(1).SaveAs "c:\windows\temp\" & notanum & ""
'    objWordApp.application.Run MacroName:="vullen"
'    objWordApp.Documents(1).SaveAs "c:\ttl account\bonnen\" & notanum & " - " & nmp & " - " & nmm & ".doc"
'    objWordApp.Documents(1).Close
'    objWordApp.Quit
    
    evenwachten.Hide

    hoofdform_opdrachtbon.Show

    Exit Sub
maken:
    Set WordObj = CreateObject("Word.Application")
    Err.Clear
    Resume Next

End Sub

Private Sub cmdSelecteren_Click()

For x% = 0 To List1.ListCount - 1
If List1.Selected(x%) = True Then
If Text1 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text1.DataField = "artikel"
    TextA1.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text1.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA1.Text = aant
    notas.Recordset.MoveLast
    Text1.DataField = ""
    TextA1.DataField = ""
ElseIf Text2 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text2.DataField = "artikel"
    TextA2.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text2.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA2.Text = aant
    notas.Recordset.MoveLast
    Text2.DataField = ""
    TextA2.DataField = ""
ElseIf Text3 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text3.DataField = "artikel"
    TextA3.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text3.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA3.Text = aant
    notas.Recordset.MoveLast
    Text3.DataField = ""
    TextA3.DataField = ""
ElseIf Text4 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text4.DataField = "artikel"
    TextA4.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text4.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA4.Text = aant
    notas.Recordset.MoveLast
    Text4.DataField = ""
    TextA4.DataField = ""
ElseIf Text5 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text5.DataField = "artikel"
    TextA5.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text5.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA5.Text = aant
    notas.Recordset.MoveLast
    Text5.DataField = ""
    TextA5.DataField = ""
ElseIf Text6 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text6.DataField = "artikel"
    TextA6.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text6.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA6.Text = aant
    notas.Recordset.MoveLast
    Text6.DataField = ""
    TextA6.DataField = ""
ElseIf Text7 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text7.DataField = "artikel"
    TextA7.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text7.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA7.Text = aant
    notas.Recordset.MoveLast
    Text7.DataField = ""
    TextA7.DataField = ""
ElseIf Text8 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text8.DataField = "artikel"
    TextA8.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text8.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA8.Text = aant
    notas.Recordset.MoveLast
    Text8.DataField = ""
    TextA8.DataField = ""
ElseIf Text9 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text9.DataField = "artikel"
    TextA9.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text9.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA9.Text = aant
    notas.Recordset.MoveLast
    Text9.DataField = ""
    TextA9.DataField = ""
ElseIf Text10 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text10.DataField = "artikel"
    TextA10.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text10.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA10.Text = aant
    notas.Recordset.MoveLast
    Text10.DataField = ""
    TextA10.DataField = ""
ElseIf Text11 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text11.DataField = "artikel"
    TextA11.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text11.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA11.Text = aant
    notas.Recordset.MoveLast
    Text11.DataField = ""
    TextA11.DataField = ""
ElseIf Text12 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text12.DataField = "artikel"
    TextA12.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text12.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA12.Text = aant
    notas.Recordset.MoveLast
    Text12.DataField = ""
    TextA12.DataField = ""
ElseIf Text13 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text13.DataField = "artikel"
    TextA13.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text13.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA13.Text = aant
    notas.Recordset.MoveLast
    Text13.DataField = ""
    TextA13.DataField = ""
ElseIf Text14 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text14.DataField = "artikel"
    TextA14.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text14.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA14.Text = aant
    notas.Recordset.MoveLast
    Text14.DataField = ""
    TextA14.DataField = ""
ElseIf Text15 = "" Then
    Clipboard.Clear
    notas.Recordset.AddNew
    Text15.DataField = "artikel"
    TextA15.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text15.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA15.Text = aant
    notas.Recordset.MoveLast
    Text15.DataField = ""
    TextA15.DataField = ""
End If
End If
Next x%
    
    Clipboard.SetText txtNummerOpdrachtbon.Text
    txtTussen1.Text = Clipboard.GetText()
    Clipboard.SetText txtNummerTandarts.Text
    txtTussen2.Text = Clipboard.GetText()

    cmdPrintenBon.Enabled = True
    
End Sub

Private Sub cmdZoeken1_Click()
    prompt$ = "Geef het nummer in."
    SearchStr$ = InputBox(prompt$)
    tandartsen.Recordset.Index = "Nummer"
    tandartsen.Recordset.Seek "=", SearchStr$
    If tandartsen.Recordset.NoMatch Then
        tandartsen.Recordset.MoveFirst
    End If
    cmdZoeken1.Enabled = False
    cmdZoeken2.Enabled = False
    cmdZoeken3.Enabled = True
    cmdSelecteren.Enabled = True
End Sub

Private Sub cmdZoeken2_Click()

comboNaam.Visible = True
cmdPlaatsen.Visible = True

Dim sql As String
Dim omschr As Recordset
Set db = OpenDatabase("c:\TTL Account\TTLAccount.mdb")

DoEvents

sql = "select naam from gegevens where naam <> '0'" & "order by naam asc;"
Set nm = db.OpenRecordset(sql, dbOpenSnapshot)

Do While Not nm.BOF And Not nm.EOF

comboNaam.AddItem nm!naam

    DoEvents
    nm.MoveNext

Loop

db.Close

cmdSelecteren.Enabled = True

End Sub

Private Sub cmdZoeken3_Click()

prompt$ = "Geef de artikelcode in."
SearchStr$ = InputBox(prompt$)
artikelen.Recordset.Index = "Artikelcode"
artikelen.Recordset.Seek "=", SearchStr$

If artikelen.Recordset.NoMatch Then
    Beep
Else

txtTussen.DataField = "Omschrijving"
Clipboard.SetText txtTussen.Text
If Text1 = "" Then
    notas.Recordset.AddNew
    Text1.DataField = "artikel"
    TextA1.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text1.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA1.Text = aant
    notas.Recordset.MoveLast
    Text1.DataField = ""
    TextA1.DataField = ""
ElseIf Text2 = "" Then
    notas.Recordset.AddNew
    Text2.DataField = "artikel"
    TextA2.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text2.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA2.Text = aant
    notas.Recordset.MovePrevious
    notas.Recordset.MoveLast
    Text2.DataField = ""
    TextA2.DataField = ""
ElseIf Text3 = "" Then
    notas.Recordset.AddNew
    Text3.DataField = "artikel"
    TextA3.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text3.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA3.Text = aant
    notas.Recordset.MoveLast
    Text3.DataField = ""
    TextA3.DataField = ""
ElseIf Text4 = "" Then
    notas.Recordset.AddNew
    Text4.DataField = "artikel"
    TextA4.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text4.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA4.Text = aant
    notas.Recordset.MoveLast
    Text4.DataField = ""
    TextA4.DataField = ""
ElseIf Text5 = "" Then
    notas.Recordset.AddNew
    Text5.DataField = "artikel"
    TextA5.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text5.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA5.Text = aant
    notas.Recordset.MoveLast
    Text5.DataField = ""
    TextA5.DataField = ""
ElseIf Text6 = "" Then
    notas.Recordset.AddNew
    Text6.DataField = "artikel"
    TextA6.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text6.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA6.Text = aant
    notas.Recordset.MoveLast
    Text6.DataField = ""
    TextA6.DataField = ""
ElseIf Text7 = "" Then
    notas.Recordset.AddNew
    Text7.DataField = "artikel"
    TextA7.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text7.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA7.Text = aant
    notas.Recordset.MoveLast
    Text7.DataField = ""
    TextA7.DataField = ""
ElseIf Text8 = "" Then
    notas.Recordset.AddNew
    Text8.DataField = "artikel"
    TextA8.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text8.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA8.Text = aant
    notas.Recordset.MoveLast
    Text8.DataField = ""
    TextA8.DataField = ""
ElseIf Text9 = "" Then
    notas.Recordset.AddNew
    Text9.DataField = "artikel"
    TextA9.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text9.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA9.Text = aant
    notas.Recordset.MoveLast
    Text9.DataField = ""
    TextA9.DataField = ""
ElseIf Text10 = "" Then
    notas.Recordset.AddNew
    Text10.DataField = "artikel"
    TextA10.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text10.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA10.Text = aant
    notas.Recordset.MoveLast
    Text10.DataField = ""
    TextA10.DataField = ""
ElseIf Text11 = "" Then
    notas.Recordset.AddNew
    Text11.DataField = "artikel"
    TextA11.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text11.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA11.Text = aant
    notas.Recordset.MoveLast
    Text11.DataField = ""
    TextA11.DataField = ""
ElseIf Text12 = "" Then
    notas.Recordset.AddNew
    Text12.DataField = "artikel"
    TextA12.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text12.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA12.Text = aant
    notas.Recordset.MoveLast
    Text12.DataField = ""
    TextA12.DataField = ""
ElseIf Text13 = "" Then
    notas.Recordset.AddNew
    Text13.DataField = "artikel"
    TextA13.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text13.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA13.Text = aant
    notas.Recordset.MoveLast
    Text13.DataField = ""
    TextA13.DataField = ""
ElseIf Text14 = "" Then
    notas.Recordset.AddNew
    Text14.DataField = "artikel"
    TextA14.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text14.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA14.Text = aant
    notas.Recordset.MoveLast
    Text14.DataField = ""
    TextA14.DataField = ""
ElseIf Text15 = "" Then
    notas.Recordset.AddNew
    Text15.DataField = "artikel"
    TextA15.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text15.Text = Clipboard.GetText()
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA15.Text = aant
    notas.Recordset.MoveLast
    Text15.DataField = ""
    TextA15.DataField = ""
End If
    
    Clipboard.SetText txtNummerOpdrachtbon.Text
    txtTussen1.Text = Clipboard.GetText()
    Clipboard.SetText txtNummerTandarts.Text
    txtTussen2.Text = Clipboard.GetText()

    cmdPrintenBon.Enabled = True

End If

End Sub

Private Sub Form_Load()

Dim sql As String
Dim omschr As Recordset
Set db = OpenDatabase("c:\TTL Account\TTLAccount.mdb")

DoEvents

sql = "select omschrijving from artikel where omschrijving <> '0'" & "order by omschrijving asc;"

Set omschr = db.OpenRecordset(sql, dbOpenSnapshot)

Do While Not omschr.BOF And Not omschr.EOF

List1.AddItem omschr!omschrijving

    DoEvents
    omschr.MoveNext

Loop

db.Close

opdrachtbon.WindowState = 2

End Sub

Gr. Jan
 
Die melding krijg je als een ander programma het clipboard open heeft, maar dat lijkt niet het geval te zijn.
Wel kan een inmiddels te snelle PC een oorzaak zijn. Plaats eens een pause van bijvoorbeeld 100 milliseconden tussen de ClipBoard.Clear en ClipBoard.SetText opdrachten.
 
Laatst bewerkt:
Alvast: Google ( deze zoekopdracht) geeft aan dat een ander programma op dat moment al met het (Windows/Office) klembord bezig is. Je code opent allerlei externe programma's (ik zie Word, ik zie Access, ...) en verder wat klembord gerelateerde acties (clipboard.clear, onder anderen).

Deze VB6 link citeert het volgende over de melding zelf:
Can't open Clipboard (Error 521)
The Clipboard has already been opened by another application. This error has the following cause and solution:

Another application is using the Clipboard and will not release it to your application.

Set an error trap for this situation in your code and provide a message box with Retry and Cancel buttons to allow the user to try again after a short pause.

Een (mogelijke) oplossing die ik vond is elke keer als je iets op het klembord zet zo'n clipboard.clear vooraf uit te laten voeren in je code. Andere suggestie is om het clip te gebruiken om hetzelfde te bereiken:
Create a Shortcut to Clear the Clipboard

A third possible workaround is to create a shortcut on the desktop running the following command on Windows 7 / Windows 10 systems. It clears the clipboard manually.

1. On the PC experiencing the issue, right-click anywhere on the desktop and choose New, Shortcut.
2. Enter the following command into the Location field:
cmd /c "echo off | clip"
3. Click Next and give the shortcut a name like "Clear Clipboard".
wat je dan zou moeten dubbelklikken elke keer voordat je met je VB6 programma gaat werken en wat de simpele tekst "echo off" op het klembord zet ipv. wat er eerder op het klembord stond. Uiteraard tackelt dit niet klembord-operaties die tijdens het gebruik van je programma plaatsvinden.

Laatste suggestie die ik vond is om (in je code) tussen klembordoperaties een (kleine) pauze in te lassen:
Clipboard.clear and clipboard.settext without a pause in between is causing the problem.... I added a sleep command = 100 and the problem disappeared!

Geen idee of je dat gaan helpen, maar dan heb je alvast wat totdat iemand anders reageert.

Tijs.
 
Laatst bewerkt:
Bedankt Thijs en Edmoor voor je snelle reactie.

het voorstel van thijs # cmd /c "echo off | clip" had ik al geprobeerd maar werkt niet.
Wat jullie allebei voorstellen kan nog wel eens de oplossing zijn en dat is de pauze.
Dit heb ik gedaan maar dan krijg ik de melding


compile error
Sub or fuction not defined

wat nu?


Code:
Private Sub cmdSelecteren_Click()

For x% = 0 To List1.ListCount - 1
If List1.Selected(x%) = True Then
If Text1 = "" Then
    Clipboard.Clear
    [COLOR="#FF0000"]Sleep 100[/COLOR]
    notas.Recordset.AddNew
    Text1.DataField = "artikel"
    TextA1.DataField = "aantal"
    txtTussen1.DataField = "notanr"
    txtTussen2.DataField = "tandarts"
    Text1.Text = List1.List(x%)
    prompt$ = "aantal:"
    aant = InputBox(prompt$, , 1)
    TextA1.Text = aant
    notas.Recordset.MoveLast
    Text1.DataField = ""
 
Je moet wel de Sleep functie declareren. Dus dit buiten de Sub:
Code:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
 
Hoi Edmoor,
Ik heb even niks van mij laten horen omdat ik eerst eens wou weten wat je bedoelde met buiten de sub plaatsen en waarom dit moet.
Declareren blijft nog moeilijk voor mij en van buiten de sub wist ik niet.
Nu wel dus en heb ik weer wat geleerd. buiten is voor het hele blad en binnen is alleen voor die sub.
Bedankt maar ook voor de oplossing want vandaag heb ik die toegepast.
De pc was inderdaad te snel en daardoor kreeg ik die foutmelding.
Nu is dat gelukkig opgelost.
nogmaals bedankt
Jan.
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan