Duane,
YES!!! I went through a series of tests and they all work correctly.
When the records are blank, the first result puts a -1 in the gteResID field, which is correct because there is only one record.
When the second score is input the gteResID field gets a 1, 2, or 3 depending on a win, loss or tie.
It is a great day and it is only 8:37 in the morning.
The last piece is to go back and change the -1 to a 1, 2 or 3 in the previous record based on the results in the second record.
Here is the code at this point.
Private Sub gtePoints_AfterUpdate()
' lngFscID is the "game" and corresponds to the gteFscID column of t_EventParticipants
' lngGteID is the primary key of t_EventParticipants
' strGL is a string value where "G" means the winner has the Greater/higher score
'Function should return:
' winner = 1
' loser = 2
' tie = 3
' NA = -1 only one result
Me.Dirty = False 'Forces a save of the current record
Me.gteResID = IsWinner(Me.gteFscID, Me.gteGteID, "G")
'Debug.Print Me.Dirty
'Debug.Print Me.gteFscID
'Debug.Print Me.gteGteID
'Debug.Print Me.gteResID
End Sub
Have a great day.
Bill
Bill Singer
From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of Bill Singer
Sent: Monday, April 5, 2021 8:23 AM
To: msaccessprofessionals@groups.io
Subject: Re: [MSAccessProfessionals] Winning team auto calculate
Duane,
I think I found it… by chance… In my testing, I had two functions called IsWinner. One was not complete. Once I deleted it I started getting the correct results. I will keep you posted.
Thanks,
Bill
Bill Singer
From: bill.singer@at-group.net <bill.singer@at-group.net>
Sent: Friday, April 2, 2021 3:35 PM
To: MSAccessProfessionals@groups.io
Subject: RE: [MSAccessProfessionals] Winning team auto calculate
Duane,
Yes there are debug statements in the function. I do not see anything in the debug window from the function. In the debug window all I see it the debug statements from the AfterUpdate action. I did verify that the AfterUpdate property for gtePoints box says [Event Procedure].
The AfterUpdate is firing because the debug prints the results.
It appears as IsWinning is not running.
Bill Singer
Minnesota.
From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of Duane Hookom
Sent: Friday, April 2, 2021 1:49 PM
To: MSAccessProfessionals@groups.io
Subject: Re: [MSAccessProfessionals] Winning team auto calculate
Hi Bill,
If you have debug statements in the function then you should see something in the debug window. Can you confirm the Event Property for the AfterUpdate of the gtePoints text box is [Event Procedure]?
Duane
From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of Bill Singer <Bill.Singer@at-group.net>
Sent: Friday, April 2, 2021 12:07 PM
To: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io>
Subject: Re: [MSAccessProfessionals] Winning team auto calculate
Duane,
Here is the code that goes in the after update property of the gtePoints field.
Using the immediate window I added a breakpoint to the code just as you said. Hovering over the variable, I verified that the variables were pulling the correct value. I used debug.print to also print them so I could watch.
I ran this with the immediate window open and the 4 Debug.print statements printed the correct information in the window (gteResID printed 0), however I believe this Sub should have triggered the Function IsWinner and then that should have also triggered variables to print out in the Immediate window. From what I can tell, this Sub never triggered the Function because I never saw anything show up in the Immediate window for the function.
The Sub below always returned a value of 0 in the gteResID field.
Private Sub gtePoints_AfterUpdate()
' lngFscID is the "game" and corresponds to the gteFscID column of t_EventParticipants
' lngGteID is the primary key of t_EventParticipants
' strGL is a string value where "G" means the winner has the Greater/higher score
'Function should return:
' winner = 1
' loser = 2
' tie = 3
' NA = -1 only one result
Me.Dirty = False 'Forces a save of the current record
Me.gteResID = IsWinner(Me.gteFscID, Me.gteGteID, "G")
Debug.Print Me.Dirty
Debug.Print Me.gteFscID
Debug.Print Me.gteGteID
Debug.Print Me.gteResID
End Sub
So close. Any thoughts?
Bill
Bill Singer
From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of Duane Hookom
Sent: Thursday, April 1, 2021 4:41 PM
To: MSAccessProfessionals@groups.io
Subject: Re: [MSAccessProfessionals] Winning team auto calculate
I always go back to using the immediate window and testing. You can add a breakpoint in your code to step through the lines one by one (with [F8]) and hovering over any variable to see its value.
Duane
Tidak ada komentar:
Posting Komentar