473,761 Members | 6,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

findfirst use

Hi everyone,

I'm using findfirst in code as below. It searches a query that shows
appointment date and account name and should return the account name of
the first appointment on each day into the same date in a calendar
form.

If rs.RecordCount 0 Then
For i = 1 To 37
If IsDate(f("date" & i)) Then
myDate = Format((f("date " & i)), "mm/dd/yyyy")
rs.FindFirst ("appdate = #" & myDate & "#")
If rs.NoMatch Then
f("text" & i).BackColor = 10944511
Else:
f("text" & i) = rs!ACCOUNTNAME
f("text" & i).BackColor = 12058551

However if I have 2 appointments on the same date it is returning the
last appointment in the query from that date. Why? From being new to
this I presumed findfirst would find the first in the list!

I am trying to get the code to return all of the appointments on each
day. I tried altering the code to this;

If rs.RecordCount 0 Then
For i = 1 To 37
If IsDate(f("date" & i)) Then
myDate = Format((f("date " & i)), "mm/dd/yyyy")
rs.FindFirst ("appdate = #" & myDate & "#")
If rs.NoMatch Then
f("text" & i).BackColor = 10944511
Else:
rs.FindNext ("appdate = #" & myDate & "#")
If Not rs.NoMatch Then
f("text" & i) = rs!ACCOUNTNAME
f("text" & i).BackColor = 12058551

Which then returns the first record on a date.

How do I get it to return both records, not one or the other?
(I am learning by trial and error and my knowledge of code is still
tiny so simple explanations would be appreciated!)

Thanks everyone.

Dec 9 '06 #1
2 2457
suggest you add an OrderBy clause to your query, so that the records are
returned in the order that you need. then add the following code to the
procedure, *before* the "If rs.RecordCount 0 Then " line, as

rs.MoveLast
rs.MoveFirst

to ensure that all the records are loaded to the recordset, and then the
FindFirst action begins at the "top" of the records.

hth
"keri" <ke*********@di ageo.comwrote in message
news:11******** **************@ 73g2000cwn.goog legroups.com...
Hi everyone,

I'm using findfirst in code as below. It searches a query that shows
appointment date and account name and should return the account name of
the first appointment on each day into the same date in a calendar
form.

If rs.RecordCount 0 Then
For i = 1 To 37
If IsDate(f("date" & i)) Then
myDate = Format((f("date " & i)), "mm/dd/yyyy")
rs.FindFirst ("appdate = #" & myDate & "#")
If rs.NoMatch Then
f("text" & i).BackColor = 10944511
Else:
f("text" & i) = rs!ACCOUNTNAME
f("text" & i).BackColor = 12058551

However if I have 2 appointments on the same date it is returning the
last appointment in the query from that date. Why? From being new to
this I presumed findfirst would find the first in the list!

I am trying to get the code to return all of the appointments on each
day. I tried altering the code to this;

If rs.RecordCount 0 Then
For i = 1 To 37
If IsDate(f("date" & i)) Then
myDate = Format((f("date " & i)), "mm/dd/yyyy")
rs.FindFirst ("appdate = #" & myDate & "#")
If rs.NoMatch Then
f("text" & i).BackColor = 10944511
Else:
rs.FindNext ("appdate = #" & myDate & "#")
If Not rs.NoMatch Then
f("text" & i) = rs!ACCOUNTNAME
f("text" & i).BackColor = 12058551

Which then returns the first record on a date.

How do I get it to return both records, not one or the other?
(I am learning by trial and error and my knowledge of code is still
tiny so simple explanations would be appreciated!)

Thanks everyone.

Dec 9 '06 #2
I already have an order by in the code, (this is above the code posted
earlier). I have tried changing the order by to another field eg.
app_time, but I get an error of too few parameters.
sql = "SELECT * FROM [querycalendar] WHERE ((MONTH(appdate ) = " &
f!month & " AND YEAR(appdate)= " & f!year & ")) ORDER BY appdate;"

Set db = CurrentDb()
Set rs = db.OpenRecordse t(sql, dbOpenSnapshot)

Dec 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
33363
by: Paul | last post by:
The 2 statements below work perfectly when using them individually. But when I try to concatenate them, they don't. rst.FindFirst " = " & OldQuoteNumber rst.FindFirst " Is Null" Can someone please let me know how its done. Thanks in advance.
1
9093
by: cnlai | last post by:
Snippets -------- Dim mydb As Database, myset As DAO.Recordset Set mydb = CurrentDb Set myset = mydb.OpenRecordset("abc") myset.FindFirst (" = 'S02'") '<< problem here Reference: MS DAO 3.6 Object Library
5
5868
by: MLH | last post by:
I have a table I can open as table type recordset or a dynaset. Searching for a particular value in the table's main keyfield, which would be faster and less strain on the application... FindFirst method - or - Seek method?
2
3167
by: rivka.howley | last post by:
I wrote some code that creates a table with a date/time field at 15-minute intervals. Here's how I create and populate the table With tblDataTemp ..Fields.Append .CreateField("CT_ID", dbLong) ..Fields.Append .CreateField(strTmpIDFld, dbLong) ..Fields.Append .CreateField(strTmpDateFld, dbDate) ..Fields.Append .CreateField(strTmpDataFld, dbDouble)
6
5966
by: Shyguy | last post by:
Is there a way to use this when entries have an apostrphe in them? Like Joe's Bar and Grill.
7
19635
by: waltvw | last post by:
I'm using FindFirst method in Access VBA to find a particular record in a recordset. I have 2 search criteria each of which works just fine if used separately as an argument in FindFirst, but NOT in combination with one another. I tried various combinations of quotes, double quotes, brackets and paranthesis but in case of using 2 conditions I'm still receiving the error message saying "run-time error 13 - type mismatch". If I use just one of...
3
3279
by: boliches | last post by:
I am trying to get a continuous form to highlight lines individually (ideally on hover). I have used the following code as recommended by a previous entry on this website. My problems begin in that my Database does not appear to recognise "FindFirst". The sample database I downloaded for help does recognise the script and when I begin to type the drop down gives the prompt for "FindFirst"! Why is it that my MDB does not? The only drop downprompt...
2
3659
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a record with double or single quotes in the location description and click a button to see if Access can tell me the ID number and find its way back to the original record. When the text contains double quotes the FindFirst works but the Dloookup...
25
3921
by: Rick Collard | last post by:
Using DAO 3.6 on an Access 2002 database, I'm getting unexpected results with the FindFirst method. Here's the simple code to test: Public Sub FindIt() Dim db As Database, rs As Recordset Dim sCriteria As String Set db = DBEngine.Workspaces(0).Databases(0) Set rs = db.OpenRecordset("tblTest", dbOpenDynaset)
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.