Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL statement against MS access

SQL statement against MS access

Scheduled Pinned Locked Moved Database
helpdatabase
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have a VB 6 Application that writes to a ms access DB. My connection works fine ( using ADO) problem is I'm trying to do a search on the table using a varible. the varible is string. I'm not sure if i have the syntax correct. PLEASE HELP Here is the code Private Sub CmdSearch_Click() Dim strSearch As String strSearch = lblSearch.Caption adoRecords.RecordSource = "SELECT * from Volenteers where In [last_name] Like strSearch ; " adoRecords.Refresh End Sub I get a error of syntax error in FROM clause strSearch is from a text box from a dialog form i had the same set up in a different program almost same sytax, and it works there I'm lost any help would be appreciated thanks

    A 1 Reply Last reply
    0
    • L Lost User

      I have a VB 6 Application that writes to a ms access DB. My connection works fine ( using ADO) problem is I'm trying to do a search on the table using a varible. the varible is string. I'm not sure if i have the syntax correct. PLEASE HELP Here is the code Private Sub CmdSearch_Click() Dim strSearch As String strSearch = lblSearch.Caption adoRecords.RecordSource = "SELECT * from Volenteers where In [last_name] Like strSearch ; " adoRecords.Refresh End Sub I get a error of syntax error in FROM clause strSearch is from a text box from a dialog form i had the same set up in a different program almost same sytax, and it works there I'm lost any help would be appreciated thanks

      A Offline
      A Offline
      afronaut
      wrote on last edited by
      #2

      Hm - I would have written it as: for exact matches - "Select * from Volunteers Where [Last_Name] = '" & strSearch & "'" for wild cards - "Select * from Volunteers Where [Last_Name] Like '" & strSearch & "%'" I believe this will work with access, try the query builder tool. *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

      J 1 Reply Last reply
      0
      • A afronaut

        Hm - I would have written it as: for exact matches - "Select * from Volunteers Where [Last_Name] = '" & strSearch & "'" for wild cards - "Select * from Volunteers Where [Last_Name] Like '" & strSearch & "%'" I believe this will work with access, try the query builder tool. *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

        J Offline
        J Offline
        jlawren7
        wrote on last edited by
        #3

        tried get error in from clause under the sql i have adorecords.recodset.refresh that gets highlighted ???

        A 1 Reply Last reply
        0
        • J jlawren7

          tried get error in from clause under the sql i have adorecords.recodset.refresh that gets highlighted ???

          A Offline
          A Offline
          afronaut
          wrote on last edited by
          #4

          Try setting a breakpoint on the line where to set your sql variable. Run the program in the debugger and set a watch for your sql variable. Once you know *exactly* what your sql statement looks like, run it in access to make sure it is syntactically correct. You may be missing a "'" or something - *->>Always working on my game, teach me *->>something new. cout << "dav1d\n";

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups