recordsource >= string in MS Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kbbauman
    New Member
    • Nov 2009
    • 6

    recordsource >= string in MS Access

    Hi,

    I was wondering if anyone could possibly help me wih this issue. I have an access database. In this database I have a massive table that I have created a query off of in order to be able to edit the data because the actual data is write protected.

    I am trying to search for certain dates in the table that have been input ex. from m/d/yyyy to m/d/yyyy. I would like to run a query that would filter the results for me.

    My basic assumptions would lead me to think that I can run a query as follows;

    Code:
    data1.recordsource = "Select * from [table] where (value in column) >= " & date1 & " and (value in column) <= " & date2 & ""
    data1.refresh
    however, this is not working for me. Any ideas??

    Thanks
    Last edited by Dököll; Nov 21 '09, 03:16 AM. Reason: code tags...
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Hey, thanks for adding the sample code...

    I am sending over to the Access Forum for you, for added support... I have also modified your title.

    Changed from "recordsour ce >= string" to "recordsour ce >= string in MS Access"

    Hope you get this one pinned down.

    In a bit!

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Originally posted by kbbauman
      In this database I have a massive table that I have created a query off of in order to be able to edit the data because the actual data is write protected.
      Before concerning ourselves with the mechanics of pulling the data with a query we really need to address the question of the data being "write protected." How is the data write protected? If it is truly Read-Only, at the table level, I suspect it will still be Read-Only after being pulled thru a query.

      Welcome to Bytes!

      Linq ;0)>

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Linq has already made the main point, but for the WHERE clause you need :
        Code:
        WHERE [FieldName] Between #m/d/yyyy# And #m/d/yyyy#
        Where the two date fields are formatted as shown but contain actual values of course.

        For a fuller explanation see Literal DateTimes and Their Delimiters (#).

        Comment

        • kbbauman
          New Member
          • Nov 2009
          • 6

          #5
          The data is "truly" write protected..... a large database that I do not have access to change. So, I designed a query off of that table that will let me change the data, but not store the changes obviously.. Thanks for the example I will try this out and let you know if it works.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Please do.

            I also recommend strongly that you check out the link. There are issues involved there that are less than straightforward and I frequently see suggestions from members that don't take all the issues into consideration properly.

            Comment

            • kbbauman
              New Member
              • Nov 2009
              • 6

              #7
              Thanks for the help issue resolved
              Code:
              Data1.RecordSource = "Select * from [table] WHERE variable = " & variable & " and [column] Between # " & date1 & " # And # " & date 2& "#"
              Data1.Refresh
              Last edited by NeoPa; Nov 23 '09, 08:50 PM. Reason: Please use the [CODE] tags provided.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Please try to pay more attention when you post.
                1. There is an edit comment on your first post explaining you should be using CODE tags when posting code.
                2. The code you post should always be copied and pasted from your project. This code clearly has not, as it would never work. It's formatted quite incorrectly.
                3. From your code you certainly don't seem to have read the linked article, or have failed to grasp the contents. Dates should not be used as they come in SQL but should always be formatted specifically.

                Comment

                Working...