473,549 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Which Record to display 1st?

I have 5records, e.g. Rc1, Rc2, Rc3..., when user open up a form, I
want it to open to a particular record (say Rc3) then when user chooses
the Record Selector [<], it will go to Rc2 and [>], it will go to Rc4.

If I use Sort in the query, it is sorted alphabetically;
if I do not sort, whatever is the latest record will be on top.

Any help/insight will be appreciated.

Perry

Nov 13 '05 #1
17 2055
Would something like this work? If so, what is the proper syntax?

DoCmd.FindRecor d (Now() >= [Date1] And Now() < [Date2])

Nov 13 '05 #2
pe******@yahoo. com wrote in
news:11******** **************@ z14g2000cwz.goo glegroups.com:
I have 5records, e.g. Rc1, Rc2, Rc3..., when user open up a form,
I want it to open to a particular record (say Rc3) then when user
chooses the Record Selector [<], it will go to Rc2 and [>], it
will go to Rc4.

If I use Sort in the query, it is sorted alphabetically;
if I do not sort, whatever is the latest record will be on top.


Records are presented in the order that you tell them via the SORT
ORDER of the underlying query, or via that property on the form (I
prefer the former, since you can always override it with the latter
if you need to).

If there is no sort order set in the underlying recordsource or in
the form, the records will appear in an unpredictable order. If you
have a non-random Autonumber field as the first field in your
recordset, it will often sort in Autonumber order, which would be
the order the records were added.

If you want it sorted by date, then sort it by date.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3
pe******@yahoo. com wrote in
news:11******** **************@ f14g2000cwb.goo glegroups.com:
Would something like this work? If so, what is the proper syntax?

DoCmd.FindRecor d (Now() >= [Date1] And Now() < [Date2])


You need bookmark navigation, using the form's Recordsetclone.

With Me.RecordsetClo ne
.FindFirst "[Date1]<=#" & Date() & "# AND [Date2]>#" & Date() &
"#" If .NoMatch Then
MsgBox "No records matched your criteria."
Else
Me.Bookmark = .Bookmark
End If
End With

Now, I changed a number of things in your criteria. First, I used
Date() instead of Now(), since Now() returns a date/time, including
the time part, whereas Date() returns just the date part. If your
field is storing only dates, then you don't need to compare it to
the current date/time, just to the current date.

Secondly, I changed the order of criteria. You had them defined
backwards to my way of thinking, comparing the dynamic value to the
stored value. I guess there's actually nothing wrong with that, but
it looks wrong!

Of course, I'm not entirely certain that reversing the signs gets
exactly the same result.

It could be that this criterion definition for the .FindFirst:

Date() Between [Date1] And [Date2]

might actually work, as well, but it depends on how important the
boundary for Date2 is, because the Between operator is inclusive, if
I'm not mistaken.

Now, the other issue is that I wouldn't use bookmark navigation for
this at all, because you're not going to a single record. That is,
there could be many records that match your criteria, so you don't
know which one you're going to end up on.

For the criteria you gave, instead of sorting them and then
navigating to the first one, I'd just filter the form to display
only the records you seek. That can be done either by setting the
form's .Filter property (and then turning it on by setting
Me.FilterOn = True) to the criteria in the .FindFirst above, or by
changing the form's underlying recordsource.

I'm more likely to do the latter because I find filters to be too
easily changed or lost, with no method for undoing additional
filtering/sorting one step at a time. If you change the underlying
recordsource, the user can filter and sort the result to her heart's
content without mucking up the basic data set.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
First find the id of the record you want to start with using iStartRecordID
= DLookup("ID",3T ableName","Your Criteria")
Then use DoCmd.FindRecor d iStartRecordID in the OnLoad-Event

Filip
<pe******@yahoo .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I have 5records, e.g. Rc1, Rc2, Rc3..., when user open up a form, I
want it to open to a particular record (say Rc3) then when user chooses
the Record Selector [<], it will go to Rc2 and [>], it will go to Rc4.

If I use Sort in the query, it is sorted alphabetically;
if I do not sort, whatever is the latest record will be on top.

Any help/insight will be appreciated.

Perry

Nov 13 '05 #5
Filip and others,
First, thank you all for your input. I am very green in VBA.
Here is what I have, but it is not working

On Form Open,

Dim iStartRecordID As Variant
iStartRecordID = DLookup("FieldN ame", "TableName" , Now() >=
[FieldName] And Now() < ([FieldName] + 60))
DoCmd.FindRecor d iStartRecordID

Perry

Nov 13 '05 #6
David,
Your method worked. Thank you. However, it is a little more
complicated... Here is a more detail about my form:

Main Form w/ one Subform. These record find is within the subform. If
the main form is first opened, your method works beautifully when I put
the codes in the Form_Open event. If now, I jump to another record in
the subform, the code stops working. (I have tried to put it in
on_change, on_query, on_current, on_lostfocus... nothing seems to
work.) What am I doing wrong?

Perry

Nov 13 '05 #7
pe******@yahoo. com wrote in
news:11******** **************@ g47g2000cwa.goo glegroups.com:
Your method worked. Thank you. However, it is a little
more
complicated... Here is a more detail about my form:

Main Form w/ one Subform. These record find is within the
subform. If the main form is first opened, your method works
beautifully when I put the codes in the Form_Open event. If now,
I jump to another record in the subform, the code stops working.
(I have tried to put it in on_change, on_query, on_current,
on_lostfocus... nothing seems to work.) What am I doing wrong?


Is your subform displaying child records of the parent form?

If you want to navigate within a subform, just replace this in the
code:

With Me.RecordsetClo ne

with:

With Me!SubformName. Form.RecordsetC lone

and it should work just fine.

Of course, again, I still think you should be filtering, not using
bookmark navigation.

Also, one thing I left out in my code, before you set Me.Bookmark =
Me.RecordsetClo ne.Bookmark, you should add:

If Me.Dirty Then Me.Dirty = False

Why not just save the record in all cases? Because that causes
problems if your back end is replicated.

[BTW -- it's considered impolite to both post and email. I don't
respond to emailed question, only in the newsgroup]

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
David,
I appoligize. I did not know that [in the BTW comment]. I will
give your codes a try tomorrow am. I will post the results here.

BTW, where should I place this code in? On_Current? On_update?

Perry

Nov 13 '05 #9
David,
I appoligize. I did not know that [in the BTW comment]. I will
give your codes a try tomorrow am. I will post the results here.

BTW, where should I place this code in? On_Current? On_update?

Perry

Nov 13 '05 #10

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

Similar topics

1
1772
by: SAN CAZIANO | last post by:
I have to insert a button in the left of all record in a table to print the current record, simply create a table and print it in the printer. anyone have an idea or there is a printer/report utility
3
13811
by: Michael Charney | last post by:
I have a form where records are entered. I have turned off the built in record control. I created buttons to advance and go back through the records as well as an add new record button, but I also want to display the current record number. I have a blank control on the form to display the number but I can not figure out how to assign it to...
3
2904
by: DataBard007 | last post by:
My Access 97 database has a form that contains text boxes that display people's names, addresses, phone numbers, etc. The record source is a single table. I created a NextRecord and Previous Record command button that, when clicked, will display the next record and the previous record, respectively. But what if I want a quick glance at all...
12
20874
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database contains the paths to the pictures. The database consists of two tables: TABLE DATA ID Name LastName
6
2857
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the...
4
5523
by: Susan Bricker | last post by:
I have a form that displays record information in Continuous Record display (scrollable list). One of the fields in the record is an Integer value called "rcode" (reason code). But, I don't want to display the reason code integer value. I want to display the reason code descriptive text (string data). So I have a TEXT BOX object on the...
0
1725
by: sumitdipsite2005 | last post by:
I am trying to use VB6 as a middleware between two 3rd party applications. "App. A" ----> VB6 ------> "App B" i am having no trouble sending data from VB to the "App B". But i am having some trouble in reading data from "App A".
3
2222
by: Gord | last post by:
If I have a form open with a subform control on it in datasheet view that has its record source set to a query or a table, is it possible to determine which record the user has clicked into with VB? I don't mean the text box with which you can determine the field/column, but the record (row). I guess what I'm looking for would be the...
0
2695
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to display the records in the text box based on my selection. I have given my selection in the combo box. For example from the student table, I am...
0
7542
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7467
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...
1
7500
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...
1
5385
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5110
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...
0
3514
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...
1
1961
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1079
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
783
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...

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.