.FindFirst Method syntax problem (1 Viewer)

DALeffler

Registered Perpetrator
Local time
Today, 10:18
Joined
Dec 5, 2000
Messages
263
I've developed a form with an unbound txtbx and a subform that behaves exactly like the Access 97 Help Index pop-up form. The unbound txtbx is used as the look-up field for the records displayed in the subfrm where I display 4 records at a time. As in the help index pop-up form, the keystrokes entered by a user display the sbfrm records that are the closest match to the text entered. My problem is in using the .FindFirst method for the recordset I open in the code behind the OnChange event for the txtbx: it doesn't survive the user entering a doublequote or a left bracket and who knows what other characters.

I'm using this syntax:

Private Sub txtLkUp_Change()

...variable & rst declarations

With rstLstNme
If Len(Me![txtLkUp].Text) = 0 Then
.MoveFirst
GoTo Mrk1
End If
strLkUpLC = LCase(Me![txtLkUp].Text)
StrLkUpFnd = Chr$(34) & strLkUpLC & Chr$(42) & Chr$(34)

.FindFirst "[FullNme] Like " & StrLkUpFnd

...etc

Is there a syntax for the .FindFirst method that doesn't blow up for ANY character the user might enter or do I have to trap for characters as they are entered (I've noticed the left bracket only causes an error if it is the first character entered in the txtbx...)? If I have to trap for characters, what syntax saves the most code?

Comments appreciated,

Doug.
 

simongallop

Registered User.
Local time
Today, 17:18
Joined
Oct 17, 2000
Messages
611
Guess that I must be wrong here but whenever I have used .FindFirst I thought that the search string was different for numbers and text ie my thoughts!

For Numbers
MySearch = "[NumberField] = " & NumVar
MyRS.FindFirst MySearch

For Strings
MySearch = "[TextField] = '" & TextVar & "'"
MyRS.FindFirst MySearch

ie always thought that strings had to be enclosed in single quotes.
 

Rich_Lovina

Registered User.
Local time
Tomorrow, 02:18
Joined
Feb 27, 2002
Messages
225
Doug...been looking for you since my hard disk crashed just before Xmas. Some of the emails (zipped) I sent you am desperately seeking to retrieve...Also temporarily can't email out, but can receive. Appreciate contact lovina1@optusnet.com.au
Thanks in advance...
 

Rich_Lovina

Registered User.
Local time
Tomorrow, 02:18
Joined
Feb 27, 2002
Messages
225
Doug, Tks very mcu yr email. With hols here everything still shut so cannot yet repair my harddisk (Fortunately we believe repairable, as back-up disks also failed). Also on my temp 1 gig system, Outlook Express not loading properly, hence this note. I'm after a zipfile I sent you of the last Access data model, I think sometime in September...it was possibly 3 Mbyte, or close to.
Tks very much in advance.
 

Users who are viewing this thread

Top Bottom