I have been struggling for 2 weeks now with an incrementing problem.
If you add a raceNo once then the lapno =1. If same number is added again, then the lapno should be 2 etc etc
I use A2007 but attachment is saved as A2003.
I would prefer to filter the strwhere in code on "RaceName" and "RaceNo" and exclude dates if possible.
I have attached part of the application with the tables/forms i use, if anybody can assist please?
I have an idea that the problem has to do with - strWhere = "[RaceDate] = #" & [Forms]![FrmRTmainChip]![RacingDate] & "# AND [RaceNo] = " & _
-
varRet(0)
- Dim varRet As Variant
-
Dim MyDB As DAO.Database
-
'Dim rst As DAO.Recordset
-
Dim rst2 As DAO.Recordset
-
Dim strInputString As String
-
Dim strWhere As String
-
Dim intLapNum As Integer
-
-
If IsNull(Me![strinput1]) Then Exit Sub
-
-
Set MyDB = CurrentDb
-
Set rst2 = MyDB.OpenRecordset("RaceEntry2", dbOpenDynaset, dbAppendOnly)
-
-
strInputString = Me![strinput1]
-
-
'See if Trailing Comma (,) is present, if so Extract it!
-
If Right$(strInputString, 1) = "," Then
-
strInputString = Left$(strInputString, Len(strInputString) - 1)
-
End If
-
-
varRet = Split(strInputString, ",")
-
-
'Let's find the Lap Number based on the Race Date, Race Name, and Race Number - THE RACENAME HAS A PROBLEM _ TEMPORARILY REMOVED
-
'strWhere = "[RaceDate] = #" & [Forms]![FrmRTmainChip]![RacingDate] & "# AND " & _
-
"[RaceName] = '" & Forms![FrmRTmainChip]![RaceName] & "' AND [RaceNumber] = " & _
-
varRet(0)
-
strWhere = "[RaceDate] = #" & [Forms]![FrmRTmainChip]![RacingDate] & "# AND [RaceNo] = " & _
-
varRet(0)
-
intLapNum = Nz(DMax("[LapNo]", "RaceEntry2", strWhere), 0)
-
-
'Select Case UBound(varRet) 'How many Race Numbers?
-
'Case 0 '1 Race#
-
-
With rst2
-
.AddNew
-
![RaceName] = Forms![FrmRTmainChip]![RaceName]
-
![RaceNo] = varRet(0)
-
![FinishTime] = Format(Now(), "General Date")
-
![RaceDate] = [Forms]![FrmRTmainChip]![RacingDate]
-
![Lapno] = IIf(intLapNum = 0, 1, intLapNum + 1)
-
.Fields("Lap" & CStr(intLapNum + 1)) = Format(Now(), "General Date")
-
-
.Update
-
End With
-
rst2.Close
-
Set rst2 = Nothing
-
-
Me.strinput1.Value = ""
-
-
'Me.Requery
-
-
[Forms]![FrmRTmainChip]![RaceEntry2sf].Requery
-
-
With Me
-
![text1].SetFocus 'Can use any Control
-
![strinput1].SetFocus
-
End With
7 1790
I have just cleaned up the code a bit and rather use the new attachment below please
RaceName = textfieldtype ; Racenumber =number ; RaceDate =long date; LapNo=number type - Dim varRet As Variant
-
Dim MyDB As DAO.Database
-
Dim rst2 As DAO.Recordset
-
-
Dim strWhere As String
-
Dim intLapNum As Integer
-
-
If IsNull(Me![strInput1]) Then Exit Sub
-
-
Set MyDB = CurrentDb
-
Set rst2 = MyDB.OpenRecordset("RaceEntry2", dbOpenDynaset, dbAppendOnly)
-
-
-
'Let's find the Lap Number based on the Race Date, Race Name, and Race Number
-
'strWhere = "[RaceDate] = #" & [Forms]![frmXCTiming]![RacingDate] & "# AND " & _
-
"[RaceName] = '" & Forms![frmXCTiming]![RaceName] & "' AND [RaceNumber] = " & _
-
varRet(0) - THE RACENAME HAS A PROBLEM _ TEMPORARILY REMOVED
-
strWhere = "[RaceDate] = #" & [Forms]![frmXCTiming]![Racedate] & "# AND [RaceNo] = " & _
-
Me.strInput1
-
intLapNum = Nz(DMax("[LapNo]", "RaceEntry2", strWhere), 0)
-
-
-
With rst2
-
.AddNew
-
![RaceName] = Forms![frmXCTiming]![RaceName]
-
![RaceNo] = Me.strInput1
-
![FinishTime] = Format(Now(), "General Date")
-
![Racedate] = [Forms]![frmXCTiming]![Racedate]
-
![Lapno] = IIf(intLapNum = 0, 1, intLapNum + 1)
-
.Fields("Lap" & CStr(intLapNum + 1)) = Format(Now(), "General Date")
-
-
.Update
-
End With
-
rst2.Close
-
Set rst2 = Nothing
-
-
Me.strInput1.Value = ""
-
-
'Me.Requery
-
-
[Forms]![frmXCTiming]![RaceEntry2SF].Requery
-
-
With Me
-
![Text1].SetFocus 'Can use any Control
-
![strInput1].SetFocus
-
End With
zmbd 5,501
Expert Mod 4TB
Ok,
I haven't opened your attachment... but I have a question... is the "RaceNo" always a unique value or is it only unique within a given date and racename?
Basic trouble shooting:
As given in your second post:
As you don't give any details as to what is actually happening, errors, etc..., I can only guess that you are getting the new record entry that lines 23-33 are calling for and that the value in [Lap] is only returning a value of 1 and the remaining field values are correct.
Working on that assumption:
Let check how your conditional is resolving and if you
actually have any returned information in your dmax on line 20
as listed in your Second posted code:
At Line 21 or 22; enter STOP compile and save
Run your application entering the racenumber or whatever it is that you need to get the application to this point.
Upon entering break mode and the VBA editor showing
<ctrl+g>
in immediate window ?strwhere ?intLapNum
Check these results against what you're expecting.
Please post back the result for the strwhere.
It does not increment the lapno field when a RaceNo is added.
Every RaceNo is unique to one person for that race. If a race consists of ie 5 laps that a RaceNo and finishtime will be added to the DB untill the 5 laps are completed.
I think my problem is with line 8+9
zmbd 5,501
Expert Mod 4TB
8 and 9 maybe; however, you only increase my suspicion that you have a malformed string.
Do as you want; however, it would be helpful to have the information I asked for....
Zmbd, a friend came to my rescue yesterday and in between a kids party at home we fixed it last night (South Africa time).
The VBA producing my required results for anybody interested,looks like this. I removed the strwhere - Dim varRet As Variant
-
Dim MyDB As DAO.Database
-
Dim rst2 As DAO.Recordset
-
Dim intLapNum As Integer
-
If IsNull(Me![strInput1]) Then Exit Sub
-
Set MyDB = CurrentDb
-
Set rst2 = MyDB.OpenRecordset("RaceEntry2", dbOpenDynaset, dbAppendOnly)
-
intLapNum = Nz(DMax("[LapNo]", "RaceEntry2", "[RaceNo] = " & Me![strInput1] & _
-
" AND [RaceName] = '" & [Forms]![frmxctiming]![RaceName] & "'"), 0)
-
With rst2
-
.AddNew
-
![RaceName] = Forms![frmxctiming]![RaceName]
-
![RaceNo] = Me.strInput1
-
![finishtime] = Format(Now(), "General Date")
-
![Racedate] = [Forms]![frmxctiming]![Racedate]
-
![Lapno] = IIf(intLapNum = 0, 1, intLapNum + 1)
-
.Fields("Lap" & CStr(intLapNum + 1)) = Format(Now(), "General Date")
-
-
.update
-
End With
-
rst2.close
-
Set rst2 = Nothing
-
-
Me.strInput1.Value = ""
-
-
'Me.Requery
-
-
[Forms]![frmxctiming]![RaceEntry2SF].Requery
-
-
With Me
-
![Text1].SetFocus 'Can use any Control
-
![strInput1].SetFocus
-
End With
zmbd 5,501
Expert Mod 4TB
Which for me adds a lot of weight to the malformed string hypothesis, which you might have confirmed using the method I offered and the information it would have returned.
NeoPa 32,556
Expert Mod 16PB Sign in to post your reply or Sign up for a free account.
Similar topics
by: Keith |
last post by:
Is there a way to publish only one file in VS.NET 2003 using FPSE method?
In FP client I can select one file at a time to publish.
My web is large and it takes too long to publish the whole...
|
by: Velhari |
last post by:
Hi all,
We all know in GET method upto 2048 characters can be appended into URL. In the Same way what is the limit of sending data to server by using POST Method. Why asking this question...
|
by: =?Utf-8?B?am9obmFicmFoYW0xMDE=?= |
last post by:
hello,
I'm trying to write a some text to a text file using WriteAllText method.
This method works fine but I don't understand how can I use format specifiers
to format the text as we use in C i.e...
|
by: jackiepajo |
last post by:
I want to delete a picture that i uploaded but icannot delete... by the way im using recordset but i do not how it really works... i just want to have some delete functio... please help..
|
by: 2pt2mill |
last post by:
I have been using SharpZipLib for over a year with no problems, but it doesn't support files zipped using compression method 6 (Imploding). This seems to be an older method of compression utilized...
|
by: munusoni |
last post by:
Hi everyone,
i am using ASP 3.0 to create web pages for a college project and i am
having problems in using recordset object through session object to
pass data to all web pages.Anyone tell me how...
|
by: JohnDriver |
last post by:
Hi,
I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
|
by: DKn |
last post by:
Hi,
I am doing shutdown for a remote system using this method
InvokeMethod("Win32Shutdown", inParams, null); in C#.Net 2.0.
Once the shutdown is done, how to get the status , whether the...
|
by: Neelesh2007 |
last post by:
Hi all,
I have project with VB6.0 and Access-2003. I have datagrid and ADODC as datasource to retrieve records from database. To export the data of datagrid to Excel I am using Copy From Recordset...
|
by: Rakulkumar |
last post by:
how can i print the pdf file using binarywrite method in asp.i can print the text file using Response.binarywrite method but i cnat print the pdf files
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |