Results 1 to 6 of 6

Thread: Inherited Query

  1. #1
    Join Date
    Feb 2005
    Posts
    24

    Unanswered: Inherited Query

    I have inherited a database that has a query in it the is driven by a form. I know there is code in the form that is supplying the criteria for the query, but i can't figure out how it is done. I have attached a jpg of the query. Any help will be appreciated.
    Attached Thumbnails Attached Thumbnails query.jpg  

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    There is nothing there that refers to a form. What is the code in the form? Perhaps it is building the query there.
    Paul

  3. #3
    Join Date
    Feb 2005
    Posts
    24
    Here is the code that i think is running the query.

    Dim dynCurrentConsumers As DAO.Recordset
    Dim dynPreviousConsumrs As DAO.Recordset

    Dim boolRepeatConsumer As Boolean

    Set qdfCurrentConsumersSearch = dbCurrent.QueryDefs![Current Consumers Query]
    Set qdfPreviousConsumersSearch = dbCurrent.QueryDefs![Previous Consumers Query]

    'fill both queries with values from current consumer in open form
    With dynConsumers

    'test
    Dim test As String
    test = "SELECT Calls.CallID, Consumers.ConsumerID, Consumers.FirstName, Consumers.LastName, Consumers.AddressLine1, Consumers.City, Consumers.PostalCode " & _
    "FROM Consumers INNER JOIN Calls ON Consumers.ConsumerID = Calls.ConsumerID " & _
    "WHERE (((Consumers.FirstName)='" & ![FirstName] & "') AND ((Consumers.LastName)='" & ![LastName] & "')) OR (((Consumers.AddressLine1)='" & ![AddressLine1] & "') AND ((Consumers.City)='" & ![City] & "') AND ((Consumers.PostalCode)='" & ![PostalCode] & "')) OR (((Consumers.LastName)='" & ![LastName] & "') AND ((Consumers.AddressLine1)='" & ![AddressLine1] & "')) OR (((Consumers.AddressLine1)='" & ![AddressLine1] & "') AND ((Consumers.PostalCode)='" & ![PostalCode] & "')) OR (((Consumers.LastName)='" & ![LastName] & "') AND ((Consumers.City)='" & ![City] & "')) OR (((Consumers.LastName)='" & ![LastName] & "') AND ((Consumers.PostalCode)='" & ![PostalCode] & "')) OR (((Consumers.FirstName)='" & ![FirstName] & "') AND ((Consumers.AddressLine1)='" & ![AddressLine1] & "'));"

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    That looks like it, yes (I'm sure there's more to it). This type of thing:

    ..." & ![FirstName] & "...

    is concatenating the currently displayed name on the form into the SQL of the query, which is why it just says "Amanda" when you look at it in design view.
    Paul

  5. #5
    Join Date
    Feb 2005
    Posts
    24
    Okay, that makes sense now.

    Thanks for the help. I really appreciate it.

    This forum has helped me in many ways and I would like to give a big thank you to everyone who takes their valuable time to help.

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problem; happy to help out.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •