How do you use a select on a Access DB & How do you update a recordset.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How do you use a select on a Access DB & How do you update a recordset.

  1. #1
    C-Man Guest

    How do you use a select on a Access DB & How do you update a recordset.


    I am writing a program and I am using an ADO control to run a
    search on a number of fields binded to an Access DB. I keep having
    problems with the search. If you could give me any assistance on this, I
    would very grateful of you. Here is the code:


    Dim pstrFacilityName As String

    pstrFacilityName = InputBox("Enter Name to be Searched?", " Search")
    adoDataControl.RecordSource = "select * from Table " & _
    " where COMPLEX like '*" & pstrFacilityName & "*' " & _
    ' " COUNTRY like '%" & pstrFacilityName & "%'"
    "ARCHITECT like '%" & pstrFacilityName & "%' or " & _
    ' "AREA like '%" & pstrFacilityName & "%' or " & _
    ' "PO_BOX like '%" & pstrFacilityName & "%' or " & _
    ' "ROOM_NUMBER like '%" & pstrFacilityName & "%' or " & _
    ' "FILE like '%" & pstrFacilityName & "%' or " & _
    ' "CITY like '%" & pstrFacilityName & "%' or " & _
    ' "STATE like '%" & pstrFacilityName & "%' or " & _
    ---------------------------------------------------------------------------------------------------------------
    I am having trouble updating a recordset. I keep getting the error, "QUERY
    IS TOO COMPLEX", I have no
    idea what I am doing wrong, Can anyone help? This is a piece of code (above)
    as well that goes with the
    updating.
    Thanks,
    C-MAN







  2. #2
    Joe Maki Guest

    Re: How do you use a select on a Access DB & How do you update a recordset.


    Unless it's a typing error, you have no Or operator after the first two select
    criteria. Also your search criteria is pretty meaningless if you apply it
    to every field. You'd be better off giving the user a combobox to select
    the field to search on and then leting them type in the criteria. You can
    then build the search string:


    adoDataControl.RecordSource = "select * from Table " & _
    " where " & cboField.text & " like '*" & pstrFacilityName & "*'"


    ...joe joewmaki@hotmail.com

    >Dim pstrFacilityName As String
    >
    > pstrFacilityName = InputBox("Enter Name to be Searched?", " Search")
    > adoDataControl.RecordSource = "select * from Table " & _
    > " where COMPLEX like '*" & pstrFacilityName & "*' " & _
    >' " COUNTRY like '%" & pstrFacilityName & "%'"
    > "ARCHITECT like '%" & pstrFacilityName & "%' or " & _
    >' "AREA like '%" & pstrFacilityName & "%' or " & _
    >' "PO_BOX like '%" & pstrFacilityName & "%' or " & _
    >' "ROOM_NUMBER like '%" & pstrFacilityName & "%' or " & _
    >' "FILE like '%" & pstrFacilityName & "%' or " & _
    >' "CITY like '%" & pstrFacilityName & "%' or " & _
    >' "STATE like '%" & pstrFacilityName & "%' or " & _
    >---------------------------------------------------------------------------------------------------------------
    >I am having trouble updating a recordset. I keep getting the error, "QUERY
    >IS TOO COMPLEX", I have no
    >idea what I am doing wrong, Can anyone help? This is a piece of code (above)
    >as well that goes with the
    >updating.
    > Thanks,
    > C-MAN
    >
    >
    >
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center