PC Review


Reply
Thread Tools Rate Thread

Data access and Domain Functions

 
 
Jason
Guest
Posts: n/a
 
      5th Jul 2004
I am developing a lapscoring database. The riders number
is taken, thier previous lap is looked up to determine
how many laps they have done

Its really weird, I tried using DAO - findlast() method,
it looks up the last record in the table with a memberID
as the criteria, seems to work good until about lap 5 -
stops finding the last record - sometimes. I use it to
increment the next lap i.e. the next lap = the last lap
for that member + 1.

The problem seems inconsistent. I tried using a query for
the data source, tried using "DLAST" method on the table
direct - same problem. I even moved the table out of
Access into MYSQL - same problem. Had a bit more luck
using "DMAX" but I still don't trust it.


Code below:
Set rstLapScore = CurrentDb.OpenRecordset("select
* from tblLapScore where raceid = " _
& intRaceID & "and
RiderNumber = '" & strNumber & "'", dbOpenDynaset)

'Set rstLapScore = CurrentDb.OpenRecordset
("qryLapScoreRider", dbOpenDynaset)

With rstLapScore
'>>>>>>>>>>>>>>>>>>>>>>>>>>> problem is below
intLap = Nz(DMax
("Lap", "tblLapScore", "RiderNumber = '" & strNumber
& "'"), 0) + 1

'add rider's lap
.AddNew
!RaceID = intRaceID
!SignOnID = intSignOnID
!RiderNumber = strNumber
!lap = intLap
.Update

End With
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      5th Jul 2004
Jason wrote:

>I am developing a lapscoring database. The riders number
>is taken, thier previous lap is looked up to determine
>how many laps they have done
>
>Its really weird, I tried using DAO - findlast() method,
>it looks up the last record in the table with a memberID
>as the criteria, seems to work good until about lap 5 -
>stops finding the last record - sometimes. I use it to
>increment the next lap i.e. the next lap = the last lap
>for that member + 1.
>
>The problem seems inconsistent. I tried using a query for
>the data source, tried using "DLAST" method on the table
>direct - same problem. I even moved the table out of
>Access into MYSQL - same problem. Had a bit more luck
>using "DMAX" but I still don't trust it.
>
>
>Code below:
> Set rstLapScore = CurrentDb.OpenRecordset("select
>* from tblLapScore where raceid = " _
> & intRaceID & "and
>RiderNumber = '" & strNumber & "'", dbOpenDynaset)
>
> 'Set rstLapScore = CurrentDb.OpenRecordset
>("qryLapScoreRider", dbOpenDynaset)
>
> With rstLapScore
>'>>>>>>>>>>>>>>>>>>>>>>>>>>> problem is below
> intLap = Nz(DMax
>("Lap", "tblLapScore", "RiderNumber = '" & strNumber
>& "'"), 0) + 1
>
> 'add rider's lap
> .AddNew
> !RaceID = intRaceID
> !SignOnID = intSignOnID
> !RiderNumber = strNumber
> !lap = intLap
> .Update
>
> End With



Not sure I follow all the attempts above, but you should be
aware that Last and DLast refer to the last record found in
an unordered bag of records (i.e a table) so they are nearly
usles for this purpose. The easiest way to get the latest
lap is to use the TOP predicate and an ORDER BY clause:

strSQL = "SELECT TOP 1 table,* " _
& "FROM tblLapScore " _
& "WHERE raceid = " & intRaceID _
& " And RiderNumber = '" & strNumber & "' " _
& "ORDER BY lap DESC"
Set rstLapScore = CurrentDb.OpenRecordset(strSQL, _
dbOpenDynaset)
With rstLapScore
If .RecordCount > 0 Then
intLap = !Lap + 1
Else
intLap = 1
End If
.AddNew
. . .
--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Jason
Guest
Posts: n/a
 
      5th Jul 2004
Marshall

Thank you very much for this fix. I also checked out
Predicates on google, this will be a valuable tool.

Regarding the rational behind my attempts to get around
the problem I had - tiredness and blind aggravation are
my only excuses OH and chuck in a bit of ignorance too.

Thanks again.

Regards Jason Willis


>-----Original Message-----
>Jason wrote:
>
>>I am developing a lapscoring database. The riders

number
>>is taken, thier previous lap is looked up to determine
>>how many laps they have done
>>
>>Its really weird, I tried using DAO - findlast()

method,
>>it looks up the last record in the table with a

memberID
>>as the criteria, seems to work good until about lap 5 -
>>stops finding the last record - sometimes. I use it to
>>increment the next lap i.e. the next lap = the last lap
>>for that member + 1.
>>
>>The problem seems inconsistent. I tried using a query

for
>>the data source, tried using "DLAST" method on the

table
>>direct - same problem. I even moved the table out of
>>Access into MYSQL - same problem. Had a bit more luck
>>using "DMAX" but I still don't trust it.
>>
>>
>>Code below:
>> Set rstLapScore = CurrentDb.OpenRecordset

("select
>>* from tblLapScore where raceid = " _
>> & intRaceID & "and
>>RiderNumber = '" & strNumber & "'", dbOpenDynaset)
>>
>> 'Set rstLapScore = CurrentDb.OpenRecordset
>>("qryLapScoreRider", dbOpenDynaset)
>>
>> With rstLapScore
>>'>>>>>>>>>>>>>>>>>>>>>>>>>>> problem is below
>> intLap = Nz(DMax
>>("Lap", "tblLapScore", "RiderNumber = '" & strNumber
>>& "'"), 0) + 1
>>
>> 'add rider's lap
>> .AddNew
>> !RaceID = intRaceID
>> !SignOnID = intSignOnID
>> !RiderNumber = strNumber
>> !lap = intLap
>> .Update
>>
>> End With

>
>
>Not sure I follow all the attempts above, but you should

be
>aware that Last and DLast refer to the last record found

in
>an unordered bag of records (i.e a table) so they are

nearly
>usles for this purpose. The easiest way to get the

latest
>lap is to use the TOP predicate and an ORDER BY clause:
>
>strSQL = "SELECT TOP 1 table,* " _
> & "FROM tblLapScore " _
> & "WHERE raceid = " & intRaceID _
> & " And RiderNumber = '"

& strNumber & "' " _
> & "ORDER BY lap DESC"
>Set rstLapScore = CurrentDb.OpenRecordset(strSQL, _
>

dbOpenDynaset)
>With rstLapScore
> If .RecordCount > 0 Then
> intLap = !Lap + 1
> Else
> intLap = 1
> End If
> .AddNew
> . . .
>--
>Marsh
>MVP [MS Access]
>.
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      5th Jul 2004
You're welcome.

Get some sleep and forge ahead. The ignorance will vanish
like a morning fog in the noonday sun soon enough ;-)
--
Marsh
MVP [MS Access]



Jason wrote:

>Marshall
>
>Thank you very much for this fix. I also checked out
>Predicates on google, this will be a valuable tool.
>
>Regarding the rational behind my attempts to get around
>the problem I had - tiredness and blind aggravation are
>my only excuses OH and chuck in a bit of ignorance too.
>
>Thanks again.
>
>Regards Jason Willis
>
>
>>-----Original Message-----
>>Jason wrote:
>>
>>>I am developing a lapscoring database. The riders

>number
>>>is taken, thier previous lap is looked up to determine
>>>how many laps they have done
>>>
>>>Its really weird, I tried using DAO - findlast()

>method,
>>>it looks up the last record in the table with a

>memberID
>>>as the criteria, seems to work good until about lap 5 -
>>>stops finding the last record - sometimes. I use it to
>>>increment the next lap i.e. the next lap = the last lap
>>>for that member + 1.
>>>
>>>The problem seems inconsistent. I tried using a query

>for
>>>the data source, tried using "DLAST" method on the

>table
>>>direct - same problem. I even moved the table out of
>>>Access into MYSQL - same problem. Had a bit more luck
>>>using "DMAX" but I still don't trust it.
>>>
>>>
>>>Code below:
>>> Set rstLapScore = CurrentDb.OpenRecordset

>("select
>>>* from tblLapScore where raceid = " _
>>> & intRaceID & "and
>>>RiderNumber = '" & strNumber & "'", dbOpenDynaset)
>>>
>>> 'Set rstLapScore = CurrentDb.OpenRecordset
>>>("qryLapScoreRider", dbOpenDynaset)
>>>
>>> With rstLapScore
>>>'>>>>>>>>>>>>>>>>>>>>>>>>>>> problem is below
>>> intLap = Nz(DMax
>>>("Lap", "tblLapScore", "RiderNumber = '" & strNumber
>>>& "'"), 0) + 1
>>>
>>> 'add rider's lap
>>> .AddNew
>>> !RaceID = intRaceID
>>> !SignOnID = intSignOnID
>>> !RiderNumber = strNumber
>>> !lap = intLap
>>> .Update
>>>
>>> End With

>>
>>
>>Not sure I follow all the attempts above, but you should

>be
>>aware that Last and DLast refer to the last record found

>in
>>an unordered bag of records (i.e a table) so they are

>nearly
>>usles for this purpose. The easiest way to get the

>latest
>>lap is to use the TOP predicate and an ORDER BY clause:
>>
>>strSQL = "SELECT TOP 1 table,* " _
>> & "FROM tblLapScore " _
>> & "WHERE raceid = " & intRaceID _
>> & " And RiderNumber = '"

>& strNumber & "' " _
>> & "ORDER BY lap DESC"
>>Set rstLapScore = CurrentDb.OpenRecordset(strSQL, _
>>

> dbOpenDynaset)
>>With rstLapScore
>> If .RecordCount > 0 Then
>> intLap = !Lap + 1
>> Else
>> intLap = 1
>> End If
>> .AddNew
>> . . .
>>--
>>Marsh
>>MVP [MS Access]
>>.
>>


 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      5th Jul 2004
Marshall Barton <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> The ignorance will vanish
> like a morning fog in the noonday sun


Poetry in a programming group..?


<g>

Tim F

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using functions after importing data from Access =?Utf-8?B?Q2hpbm55MDM=?= Microsoft Excel Discussion 1 31st May 2007 04:51 PM
Converting Oracle SQL functions to Access built-in functions GVR_Mike Microsoft Access 3 30th Jun 2006 12:33 AM
Data Access Pages and Calling ACCESS functions =?Utf-8?B?VmFsdWVkQ2xpZW50?= Microsoft Access VBA Modules 1 16th Feb 2005 04:15 PM
Protecting sensitive data on user computers from domain admin access N Jensen Microsoft Windows 2000 Active Directory 1 21st Mar 2004 01:01 PM
Are There Any Functions IN Access to Bin Data? mcl Microsoft Access Queries 1 18th Nov 2003 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:48 PM.