Page 1 of 3 123 LastLast
Results 1 to 15 of 36
  1. #1
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17

    Query misfiring and giving wrong results

    i have a query which is supposed to be bringing up all the items that have sold since a certain date.
    i have previously used a form to nominate the date as there are a few queries using the same date.
    it has just started bringing in entries that are not valid and i have no idea why.
    if i dont put open the form and put the date there it seems to work fine.
    but as soon as i put the date in the form, it no longer asks me for a date BUT also finds many more stock items which are seemingly not valid.
    i have included the query here - it should select all books in stock that have been updated after a certain date. like i said if i get asked for the date and put it in it brings up approx 150 titles which is correct. if i put the date in the form it brings up 6000.


    thx for any help.
    rob

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Nothing attached?

    Better to upload the DB?

    However what date format do you use? MS expects mm/dd/yyyy or yyyy-mm-dd
    If used in SQL string also needs to be qualified with # character.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17
    i will try and reduce the size to upload.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Compact and zip a copy of your db.
    If still too large, just upload the minimum needed to see the issue.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17

    access upload

    hi there - hope this is usable - i deleted a heap of forms reports etc to get it even close. think i left the stuff behind i need help with.
    Attached Files Attached Files

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by unclemeat View Post
    hi there - hope this is usable - i deleted a heap of forms reports etc to get it even close. think i left the stuff behind i need help with.
    It might be helpful for you to tell us which of the queries and which of the forms we should be looking at
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi

    You need to normalise your table "shopify"

    All of the following Fields should be Records in a Related Table

    Reggae
    World Music
    Women
    Metal
    Audiobooks
    Country
    Folk
    Jazz
    Indigenous
    Australian
    Collect
    Fiction
    Non Fiction
    WEBKeywords
    War
    Sport
    Politics
    Crime
    Signed
    Cookery
    Self Help
    SciFi
    Romance
    Prize
    Biography
    Nature
    Music
    History
    Historical Fiction
    Comic
    DIY
    Childrens
    Art
    Classics
    Health
    Transport
    Humour
    Poetry
    Science
    Teen
    Travel
    Spirituality
    Manuals
    Horror
    LGBTQ
    Gardening
    Documentaries
    Movies
    HIp Hop
    Box Sets
    Alternative
    Dance
    Soundtrack
    Blues
    Punk
    Compilation
    Christmas
    FNQ
    Classical
    TV
    Magazines
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Yes, it needs work. That is why you have so many queries, one for CDs one for books. You should have one query and then specify which product you want to use.
    Regardless, we still need the query and instructions on how to recreate the issue?, Also what should we expect to be correct.

    Remember, you know this DB intimately, we do not.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17
    apologies. so the query is ebaycdqry.
    if you open it and put 1/4/2023 when prompted it gives 17 results.
    if you open the reports f form and put 1/4/2023 in the date field it gives 250 results.
    the 17 results is correct - im not sure where the other records are coming from.
    the ebaycdqry should be looking for the date in reports f form (i think).

  10. #10
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17
    do you mean set up a table with say music styles and then link any relevant records to it ? i know thats how its done with condition but its only 1 value whereas some cds fit into multiple styles.

  11. #11
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    The fields I indicated should be in a table called tblStyles

    tblStyles
    -StyleID PK
    -Style
    You then need to create an additional table named tblMusicStyles

    tblMusicStyles
    -MusicStyleID - PK
    -ShopifyID - FK
    -StyleID - FK (Linked to PK tblMusicStyles)

    You can then add a number of related Styles
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    In the query, replace: >[Forms]![reports f]![date]
    with: >Format([Forms]![reports f]![date],"mm\/dd\/yyyy")

    Read what Allen Browne says about international dates in Access. See: http://allenbrowne.com/ser-36.html

    BTW I would recommend you to redesign your tables which are not "Normalized".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Bob Fitz View Post
    In the query, replace: >[Forms]![reports f]![date]
    with: >Format([Forms]![reports f]![date],"mm\/dd\/yyyy")

    Read what Allen Browne says about international dates in Access. See: http://allenbrowne.com/ser-36.html

    BTW I would recommend you to redesign your tables which are not "Normalized".
    As I suspected.

    I used this constant in my DBs for such a reason.

    Code:
    Public Const strcJetDate = "\#mm\/dd\/yyyy\#"  'Needed for dates in queries as Access expects USA format.
    as I could never remember the exact syntax. The I just used that as the format parameter.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17
    hi bob
    this is still same problem i think.
    if you open reports f and put in 4/4/2023 and open the ebaybookqry query (its pretty much the same as the cd one except for books) (with the new code under recordcreated) you get 283 records.
    if you then close reports f and run the query, it prompts for a date and so you put in 4/4/2023 you get 9 records (which i think is right). not sure why the other records are coming in - there are heaps that were last changed on 25/02/2023, 6/03/2023 etc which are obviously not greater than 4/4/2023.
    just not understanding why they are being selected by the query.
    thx
    rob

  15. #15
    unclemeat is offline Novice
    Windows 10 Access 2007
    Join Date
    Apr 2023
    Posts
    17
    where would you put that code in a database ?

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query giving strange results
    By deepakg27 in forum Queries
    Replies: 3
    Last Post: 02-11-2018, 11:17 AM
  2. Search Query not giving all results
    By wrkadri in forum Queries
    Replies: 5
    Last Post: 02-05-2013, 12:37 AM
  3. Calculation in Query giving wrong results
    By dargo72 in forum Queries
    Replies: 11
    Last Post: 11-07-2012, 05:39 AM
  4. Replies: 3
    Last Post: 07-13-2012, 09:18 AM
  5. Access giving wrong result using sql query
    By amlanroy in forum Access
    Replies: 3
    Last Post: 05-10-2012, 10:11 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