|
-
May 4th, 2006, 11:38 PM
#1
Thread Starter
Lively Member
Can anyone see any problems.
Hi guys CAn anyone see any problems with this userform which does a find and replace and puts the replacement in the second textbox.
I dont really know wether to use keyup,keypress or keydown it works when u press spacebar. I got it working with vb6 and converted it to vba but the text is not copying but not recieving any errors.
caz
heres the code:
VB Code:
Private db As DAO.Database
Private rs As DAO.Recordset
Private Sub frmContacts_Load()
Set db = OpenDatabase("C:\Documents and Settings\Matthew\Desktop\TEST.mdb")
Set rs = db.OpenRecordset("tblTEST", dbOpenDynaset)
'Points to access database.
End Sub
Private Sub TextBox1_Change()
'TextBox where text is entered.
End Sub
Private Sub txtSearchText_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'When space pressed shoudl find text in database and send result to
'TextBox1.
Dim Prts() As String
Dim tmpText As String
If KeyAscii = 32 Or KeyAscii = 46 Then
If txtSearchText.Text <> "" Then
tmpText = txtSearchText
Prts = Split(txtSearchText.Text, " ")
For X = 0 To UBound(Prts)
rs.FindFirst "[SearchText] = '" & Prts(X) & "'"
If Not rs.NoMatch Then
tmpText = Replace(tmpText, Prts(X), rs.Fields("ReplacementText"))
End If
Next
TextBox1 = tmpText
End If
End If
End Sub
Last edited by caz1805; May 4th, 2006 at 11:43 PM.
-
May 11th, 2006, 03:54 AM
#2
Re: Can anyone see any problems.
Have you put a break point on it to see where it is not working?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|