The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Do I need to kill someone at MS? by Nessalc 2009-04-02 07:50:29

Or is my code bad? I'm trying to make a "type-ahead" feature for MS Access. It needs to provide the following features:

  • pressing <TAB> or <ENTER> moves the cursor to the next field
  • if multiple entries in the lookup table match what has been typed so far, provide more fields so the proper entry can be selected

The following code should execute a SQL query and print the number of returned records in the debug window. It prints "0" when the WHERE clause is WHERE [Name] LIKE "*" but "20" when it's WHERE [Name] Is Null. Because of the initial condition, I also wound up with zero rows returned when I used the value in a text box (so the query was dynamically generated, "WHERE [Name] LIKE """ & Text0.Value & "*"""). I get precisely the opposite behavior when I run the query in the Access query window--why? And, just to be sure I'm getting the right query, I copy it from one window to the other.

Private Sub Text0_KeyPress(KeyAscii As Integer)
    If KeyAscii < 32 Then
        Text0.Value = ""
        Exit Sub
    End If
    Text0.Value = Text0.Value & Chr(KeyAscii)
    Dim sql As String
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    sql = "SELECT [User] FROM [Users] WHERE [User] LIKE '*'"
    rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
    Debug.Print sql, Text0.Value, rs.RecordCount
End Sub
[ Reply ]
  just ONE person at M$? wow (n/t) by ick2009-04-02 08:27:15
    Well, they've already neglected to fix an error by Nessalc2009-04-02 08:46:59
      Yeah, we've found a pretty bad bug in Jet4 related by bwkaz2009-04-02 09:03:19
  1) Access is evil. 2) NULL in Access is even more by bwkaz2009-04-02 09:03:12
    I do have options to use something other than Acce by Nessalc2009-04-02 09:25:21
      If the query is a pass-thru to SQL Server... by wibble2009-04-02 10:04:00
        I'm aware of that by Nessalc2009-04-02 10:38:02

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)