Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35
  1. #16
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142


    Quote Originally Posted by mikesal57 View Post
    It worked somehow....but not from the macro I created...

    Pictures of what happen when I rAn Macro....and.......pictures of when I RAN it from ALT-11 screen...
    Sorry, I'm not familiar with running vba from a macro. I think most of us try to stay away from macros in general. Is this something that will need to be repeated often? If so just call the sub from a command button on a form. Otherwise I'd just run it from the vba editor window.

    IF the format of your column names is nPOS01 through nPOS37 I propose a slight code modification:


    Code:
    Public Sub SetZerosToNull()
    On Error GoTo ErrHandler
        Dim db As DAO.Database
        Dim update_qry As String
        Dim i As Integer
        
        Set db = CurrentDb
        
        For i = 1 To 37
            update_qry = "UPDATE [ALL_HX44] SET nPOS" & Format(i, "##") & " = null WHERE nPOS" & Format(i, "##") & " = 0;"
            
            'Debug.Print update_qry
            db.Execute update_qry, dbFailOnError
        Next
    
    ExitHandler:
        Set db = Nothing
        Exit Sub
    
    ErrHandler:
        MsgBox Err.Description, , "Error #" & Err.Number
        Resume ExitHandler
    End Sub

  2. #17
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Quote Originally Posted by kd2017 View Post
    Sorry, I'm not familiar with running vba from a macro. I think most of us try to stay away from macros in general. Is this something that will need to be repeated often? If so just call the sub from a command button on a form. Otherwise I'd just run it from the vba editor window.

    IF the format of your column names is nPOS01 through nPOS37 I propose a slight code modification:


    Code:
    Public Sub SetZerosToNull()
    On Error GoTo ErrHandler
        Dim db As DAO.Database
        Dim update_qry As String
        Dim i As Integer
        
        Set db = CurrentDb
        
        For i = 1 To 37
            update_qry = "UPDATE [ALL_HX44] SET nPOS" & Format(i, "##") & " = null WHERE nPOS" & Format(i, "##") & " = 0;"
            
            'Debug.Print update_qry
            db.Execute update_qry, dbFailOnError
        Next
    
    ExitHandler:
        Set db = Nothing
        Exit Sub
    
    ErrHandler:
        MsgBox Err.Description, , "Error #" & Err.Number
        Resume ExitHandler
    End Sub
    Understood...
    Thanks KD with the great follow thru to get this working you work BIG OT on this one....

  3. #18
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Can you upload a zipped copy of the database?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #19
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    I'm still somewhere at a loss...
    Totals not adding up....

    Fields POS1 thru 5 ...have only 1's and 0's

    I thought taking out the 0's will take that field out of the equation....
    But it seems like it doesnt...

    In Pic 1....I'm showing hits on all combo's in fields POS1 thru 5

    I select the Line where POS2 and POS3
    and ran it without 1-4-5 and I get different totals

    Lost on why its happening...
    Attached Thumbnails Attached Thumbnails 1.jpg   2.JPG  

  5. #20
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Maybe you could show your equation?

    Also, this looks like a spreadsheet, this might be a job for excel. Maybe you could give us an overview of what the app is and what it's supposed to achieve.

  6. #21
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Quote Originally Posted by kd2017 View Post
    Maybe you could show your equation?

    Also, this looks like a spreadsheet, this might be a job for excel. Maybe you could give us an overview of what the app is and what it's supposed to achieve.
    No problem....
    SELECT Sum(ALL_HX4.xwin) AS Bets, Count(ALL_HX4.xfin) AS CountOfxfin, Sum(IIf([xwin]>0,1,0)) AS Winners, Sum(IIf([xWIN]>0,1,0))/Count([xwin])*100 AS [Win%], Count([xwin])/[TotalRaces] AS [Bets Per Race], Sum([xWin])/(Count([xwin])*2) AS ROI, [Winners]/[TotalRaces] AS [% of All Races], 2*[ROI]*[BETS]/[WINNERS] AS [Avg Price], Sum(IIf([xpla]>0,1,0)) AS Placers, Sum([xPla])/(Count([xpla])*2) AS PROI, Sum(IIf([xPLA]>0,1,0))/Count([xpla])*100 AS [Place%], Max(ALL_HX4.xwin) AS [Max], ALL_HX44.nPOS01, ALL_HX44.nPOS02, ALL_HX44.nPOS03, ALL_HX44.nPOS04, ALL_HX44.nPOS05
    FROM ALL_HX4 INNER JOIN ALL_HX44 ON (ALL_HX4.tTRK = ALL_HX44.tTRK) AND (ALL_HX4.tDATE = ALL_HX44.tDATE) AND (ALL_HX4.nRACE = ALL_HX44.nRACE) AND (ALL_HX4.tPGM = ALL_HX44.tPGM)
    GROUP BY ALL_HX44.nPOS01, ALL_HX44.nPOS02, ALL_HX44.nPOS03, ALL_HX44.nPOS04, ALL_HX44.nPOS05;

    what I'm trying to do is find out what combo of fields gives out the best ROI....

    Its not that hard but those damn numbers just dont jive when its done alone without those zero fields

  7. #22
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Hi Again...

    I'm still at a stop on this ...maybe it just cant be done.....if not , I need to know to stop perusing it...
    heres a little more simpler explanation

    Pic #1 & #2 is the query and results ......notice the number in red
    Pic #3 & #4 new query just adding another field.....notice the amount in red is drastically lower but it the same two fields like above
    All the fields are either 1 & zeros

    I need a condition or rule that doesnt let fields with a zero to affect the out come...
    Can this be done?
    thxs
    Mike
    Attached Thumbnails Attached Thumbnails 1.JPG   2.JPG   3.JPG   4.JPG  

  8. #23
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Can you upload a copy of the database?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  9. #24
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Going back to post #15, the reason your macro errored is because you can run functions from a macro but cannot run subs.

    I'm not going to get further involved as this approach is completely inappropriate for a database as I and many others told you at UA.
    It would be courteous to those who responded to your thread at UA if you could state that you have decided to follow another route rather than normalise your data.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #25
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Quote Originally Posted by isladogs View Post
    Going back to post #15, the reason your macro errored is because you can run functions from a macro but cannot run subs.

    I'm not going to get further involved as this approach is completely inappropriate for a database as I and many others told you at UA.
    It would be courteous to those who responded to your thread at UA if you could state that you have decided to follow another route rather than normalise your data.
    That macro is not an issue any more because if its a blank field or has a zero my queries dont give me what I'm looking for.
    I do appreciate all you guys helping , but remember that I just started using Access and do not know much of what I can or cant do...

    Normalize is not familiar to me...I did read up but I'm still confused.....
    There is nothing repetitive in my fields ...yes it does have 1's and zero's ....but thats just a way to use that field or not.....

    I hope no one takes offence to my new status

    Mike

  11. #26
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I hope no one takes offence to my new status
    No one takes offense at someone who's new to access seeking help. It's the reason many of us are here, as well as several other sites.

    Many of us do take offense to cross posting without the poster making note of it. Often we will will spend a lot of time mocking up a test database and trying out code prior to posting an answer.
    It can be awfully annoying to find out that a certain solution attempt was made already or the poster already had a solution at another site and you just wasted an hour for nothing.

    Done correctly cross posting is not an issue. We have all done it but we do it correctly by including a link to the crosspost.

    This is a link that many are commonly refered to about cross posting - https://www.excelguru.ca/content.php?184
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #27
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Quote Originally Posted by moke123 View Post
    No one takes offense at someone who's new to access seeking help. It's the reason many of us are here, as well as several other sites.

    Many of us do take offense to cross posting without the poster making note of it. Often we will will spend a lot of time mocking up a test database and trying out code prior to posting an answer.
    It can be awfully annoying to find out that a certain solution attempt was made already or the poster already had a solution at another site and you just wasted an hour for nothing.

    Done correctly cross posting is not an issue. We have all done it but we do it correctly by including a link to the crosspost.

    This is a link that many are commonly refered to about cross posting - https://www.excelguru.ca/content.php?184
    I hear you and I'm sorry....

    I started by Googleing Access Forums .....these 2 came up.......not knowing which one would satisfy me....I did post in both....
    But after all the responses , I set my tack here...

    Mike

  13. #28
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by mikesal57 View Post
    I hear you and I'm sorry....

    I started by Googleing Access Forums .....these 2 came up.......not knowing which one would satisfy me....I did post in both....
    But after all the responses , I set my tack here...

    Mike
    Your answers at UA suggested you were using that as your main source of information. As a result, several people continued to respond
    ....that is until someone else made it clear you were no longer following that advice

    Please have the courtesy to post something at UA in order to prevent anyone else wasting their time replying. Thank you.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #29
    mikesal57 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    48
    Quote Originally Posted by isladogs View Post
    Your answers at UA suggested you were using that as your main source of information. As a result, several people continued to respond
    ....that is until someone else made it clear you were no longer following that advice

    Please have the courtesy to post something at UA in order to prevent anyone else wasting their time replying. Thank you.
    I just did.....they mentioned "Normalizing Data" ...have no clue on that ...will have to read up and understand if thats my solution

    My quick read says that the data is duplicated , I dont or maybe cant see it....as my fields are different from each other tho
    its all 1's and 0's....

    I will try to make sense of it some how

    thxs

  15. #30
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Thank you for doing that
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 1
    Last Post: 01-09-2019, 02:41 PM
  2. Replacing one value for another
    By Richiebob in forum Programming
    Replies: 10
    Last Post: 05-06-2013, 11:33 AM
  3. Replacing data in a field.
    By darrellx in forum Queries
    Replies: 4
    Last Post: 08-21-2011, 10:33 AM
  4. Compiling Data, Not Replacing
    By helpaccess in forum Access
    Replies: 12
    Last Post: 03-08-2011, 03:13 PM
  5. Replacing data in Table
    By JackT in forum Import/Export Data
    Replies: 1
    Last Post: 08-23-2010, 10:34 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