Situation: I have a form with a text box that I want the user to type into. I need to detect the characters as they are being typed into the text box. Then execute some other code such as passing the text in the text box into a variable and then passing the variable into a SQL statement that is embedded in the code. What event has to be used? Here is some sample code that doesn't work because I can't figure out which event to use.
Dim myvar As String
Dim strSQL As String
Dim strLastName As String
strLastName = txtLast_Name.Value
strSQL = "SELECT dbo.CONTACT1.KEY4, dbo.CONTACT2.UMAINFNAME, dbo.CONTACT1.LASTNAME, dbo.CONTACT1.ADDRESS1, dbo.CONTACT1.CITY, "
strSQL = "SELECT dbo.CONTACT1.LASTNAME, dbo.CONTACT2.UMAINFNAME, dbo.CONTACT1.ADDRESS1, dbo.CONTACT1.CITY, dbo.CONTACT1.STATE, "
strSQL = strSQL & "dbo.CONTACT1.ZIP, dbo.CONTACT1.KEY4, dbo.CONTACT1.ADDRESS2, dbo.CONTACT1.ADDRESS3, dbo.Personnel.Personnel_Username, "
strSQL = strSQL & "dbo.Personnel_Groups.[Group] "
strSQL = strSQL & "FROM dbo.Personnel_Linking INNER JOIN "
strSQL = strSQL & "dbo.Personnel_Groups ON dbo.Personnel_Linking.Group_ID = dbo.Personnel_Groups.Group_ID INNER JOIN "
strSQL = strSQL & "dbo.Personnel ON dbo.Personnel_Linking.Personnel_ID = dbo.Personnel.Personnel_ID INNER JOIN "
strSQL = strSQL & "dbo.CONTACT1 INNER JOIN "
strSQL = strSQL & "dbo.CONTACT2 ON dbo.CONTACT1.ACCOUNTNO = dbo.CONTACT2.ACCOUNTNO ON dbo.Personnel_Groups.[Group] = dbo.CONTACT1.KEY4 "
strSQL = strSQL & "WHERE (dbo.Personnel.Personnel_Username = N'dharris') AND (dbo.CONTACT1.LASTNAME LIKE '" & strLastName & "%') "
strSQL = strSQL & " ORDER BY dbo.CONTACT1.LASTNAME, dbo.CONTACT2.UMAINFNAME "
Dim myvar As String
Dim strSQL As String
Dim strLastName As String
strLastName = txtLast_Name.Value
strSQL = "SELECT dbo.CONTACT1.KEY4, dbo.CONTACT2.UMAINFNAME, dbo.CONTACT1.LASTNAME, dbo.CONTACT1.ADDRESS1, dbo.CONTACT1.CITY, "
strSQL = "SELECT dbo.CONTACT1.LASTNAME, dbo.CONTACT2.UMAINFNAME, dbo.CONTACT1.ADDRESS1, dbo.CONTACT1.CITY, dbo.CONTACT1.STATE, "
strSQL = strSQL & "dbo.CONTACT1.ZIP, dbo.CONTACT1.KEY4, dbo.CONTACT1.ADDRESS2, dbo.CONTACT1.ADDRESS3, dbo.Personnel.Personnel_Username, "
strSQL = strSQL & "dbo.Personnel_Groups.[Group] "
strSQL = strSQL & "FROM dbo.Personnel_Linking INNER JOIN "
strSQL = strSQL & "dbo.Personnel_Groups ON dbo.Personnel_Linking.Group_ID = dbo.Personnel_Groups.Group_ID INNER JOIN "
strSQL = strSQL & "dbo.Personnel ON dbo.Personnel_Linking.Personnel_ID = dbo.Personnel.Personnel_ID INNER JOIN "
strSQL = strSQL & "dbo.CONTACT1 INNER JOIN "
strSQL = strSQL & "dbo.CONTACT2 ON dbo.CONTACT1.ACCOUNTNO = dbo.CONTACT2.ACCOUNTNO ON dbo.Personnel_Groups.[Group] = dbo.CONTACT1.KEY4 "
strSQL = strSQL & "WHERE (dbo.Personnel.Personnel_Username = N'dharris') AND (dbo.CONTACT1.LASTNAME LIKE '" & strLastName & "%') "
strSQL = strSQL & " ORDER BY dbo.CONTACT1.LASTNAME, dbo.CONTACT2.UMAINFNAME "