powerblade
Registered User.
- Local time
- Today, 23:28
- Joined
- Sep 8, 2015
- Messages
- 16
Hey,
Have a combo box Search as you type (VBA) ... In after update ( setfocus ) I get message: You can only refer to a property or method for a control if the control has the focus.
Well I have searched long for a solution. It might have something to do with .text but 've tried different things , but do not get out.
Here is the working code (search as you type combo) :
And here is the afterupdate VBA:
Thank you in advance!
Have a combo box Search as you type (VBA) ... In after update ( setfocus ) I get message: You can only refer to a property or method for a control if the control has the focus.
Well I have searched long for a solution. It might have something to do with .text but 've tried different things , but do not get out.
Here is the working code (search as you type combo) :
Code:
Private Sub lala_Change()
Dim strText As String, strFind As String, i, strSQL As String
strText = Me.lala.Text
If Len(Trim(strText)) > 0 Then
strFind = "NaamProduct Like '"
For i = 1 To Len(Trim(strText))
If (Right(strFind, 1) = "*") Then
trFind = Left(strFind, Len(strFind) - 1)
End If
strFind = strFind & "*" & Mid(strText, i, 1) & "*"
Next
strFind = strFind & "'"
Me.lala.RowSource = strSQL
Else
strSQL = "SELECT Producten.ProductId, Producten.NaamProduct, [Prijsex]*1.21 AS Prijsincl, Producten.Prijsex, IIf([Klantid] Is Null,producten!korting,poafatih!korting) AS Kortingg " _
& " FROM Producten LEFT JOIN poafatih ON Producten.ProductId = poafatih.productid " _
& " WHERE (((poafatih.Klantid) Is Not Null Or (poafatih.Klantid) Is Null)) " _
& " ORDER BY Producten.ProductId, Producten.NaamProduct, Producten.Prijseenheid, poafatih.[prijs op afspraak];"
Me.lala.RowSourceType = "Table/Query"
Me.lala.RowSource = strSQL
Me.Recalc
End If
Me.lala.Dropdown
End Sub
And here is the afterupdate VBA:
Code:
Private Sub lala_AfterUpdate()
Me![Prijseenheid] = Me![lala].Column(3)
Me![Tekst17] = Me![lala].Column(3)
Me.Hoeveelheid.SetFocus
End Sub
Thank you in advance!