Results 1 to 5 of 5
  1. #1
    Laetilae is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    4

    Exclamation !!!!Urgent!!!! Search code doesn't work!

    !!!!Urgent!!!!

    Hi everyone,
    i am new on the forum and i need some help for an access code.

    I have to make a search engine by using a textbox, database, and command button.I MUST not use wizard.
    I am using microsoft office access 2003
    the reference is Microsoft DAO 3.5 Object library as references.

    Here is the code:
    __________________________________________________ _____________
    Private Sub CmdSearch_Click()
    Dim SearchResult As DAO.Recordset
    Dim SucessfulResult

    Logonname = Trim(Forms![FrmClient]![TxtSearch])


    Set LoadTable = CurrentDb()


    Set SearchResult = LoadTable.OpenRecordset("TblClient", dbOpenDynaset)

    SearchResult.FindFirst "Client ID = '" & Logonname & "'"
    If Form_FrmClient.TxtSearch = SearchResult.Fields("Client ID") Then


    Found = True
    MsgBox "ok"


    Else
    MsgBox "Record not found."


    End If

    End Sub
    __________________________________________________ __________
    I get the following error:

    "Run-time error '3077':
    Syntax error (missing operator) in expression" and highlights the red line.

    I tried several stuffs but the code still doesn't work.
    Please help me!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Those embedded spaces will get you every time. try:
    SearchResult.FindFirst "[Client ID] = '" & Logonname & "'"

  3. #3
    Laetilae is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    4
    Thank you so much! it is working!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You are very welcome.

  5. #5
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    And remember, putting !!!!!URGENT!!! in the title and text portion doesn't make it a priority for us to answer. Allan was nice enough to answer it quickly but these kind of posts go to the bottom of my list to answer. And please state in advance if it's for a school project. That helps us to help you learn how to do it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Code does not work in 64 Bit Access 2010
    By mwolfod in forum Programming
    Replies: 26
    Last Post: 12-12-2010, 04:39 PM
  2. my search form won't work?
    By sams in forum Forms
    Replies: 5
    Last Post: 05-06-2010, 02:08 PM
  3. Replies: 4
    Last Post: 01-11-2010, 11:41 PM
  4. Query doesn't work when launched by code
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-24-2009, 09:52 AM
  5. VBA Code To Work With MySQL
    By botts121 in forum Programming
    Replies: 0
    Last Post: 07-08-2009, 08:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums