473,765 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Next Record in Query Results via Form

Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResul ts]. The subform is bound to a query [qrySearchResult s]
that returns records based on criteria in the main form. The user then
double clicks a row on the datasheet subform to open yet another form
[frmDetails] bound to a table [tblStudents]. These two forms are linked by
the [StudentID] field. So far so good.

Here' is where I'm stumped. I'd like to put a Next Record navigation button
on the [frmDetails] form so the user can go to the next record of the query
results listed in the datasheet form [sfrmSearchResul ts] instead of closing
the form and going to the next record of the datasheet. Does anyone know
the code for that? Here is what I've tried to no avail. I get a "compile
error--expected array."

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Cli ck

DoCmd.GoToRecor d , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID])

Exit_cmdNext_Cl ick:
Exit Sub

Err_cmdNext_Cli ck:
MsgBox Err.Description
Resume Exit_cmdNext_Cl ick

End Sub

Thank you for any and all help.

William

P.S. A "luxury" at this point would be if the user got a "end of record"
error message when they tried to click on the Next button but there were no
records left.



Nov 12 '05 #1
3 4761
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm assuming you have the frmDetails RecordSource property as:
tblStudents, correct? If so, you can change the RecordSource to an
SQL statement like this (watch out for line-wrap):

SELECT * FROM tblStudents WHERE StudentID =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID]

Then when the user clicks another record in the subform
sfrmSearchResul ts the form frmDetails will update to the correct
record. You may have to do a form Requery for frmDetails in the
sfrmSearchResul ts OnCurrent event procedure. E.g.:

Forms!frmDetail s.Requery

This means both forms should be visible to the user at the same time.

If there isn't a matching record in the tblStudents the frmDetails
will have empty controls. You can set the frmDetails OnCurrent event
to change the form's Title Bar like this:

Me.Caption = "Student ID: " & IIf(IsNull(Me!S tudentID), _
"No Record",Me!Stud entID)

This will tell the user if a record is present or not.

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP84rm4echKq OuFEgEQJBUgCeOG GrrqW0/BrIapd+I6M05oG0 qasAoOLv
c/0SEKbzFnUWHl5xO ItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResul ts]. The subform is bound to a query [qrySearchResult s]
that returns records based on criteria in the main form. The user then
double clicks a row on the datasheet subform to open yet another form
[frmDetails] bound to a table [tblStudents]. These two forms are linked by
the [StudentID] field. So far so good.

Here' is where I'm stumped. I'd like to put a Next Record navigation button
on the [frmDetails] form so the user can go to the next record of the query
results listed in the datasheet form [sfrmSearchResul ts] instead of closing
the form and going to the next record of the datasheet. Does anyone know
the code for that? Here is what I've tried to no avail. I get a "compile
error--expected array."

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Cli ck

DoCmd.GoToRecor d , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID])

Exit_cmdNext_Cl ick:
Exit Sub

Err_cmdNext_Cli ck:
MsgBox Err.Description
Resume Exit_cmdNext_Cl ick

End Sub

Thank you for any and all help.

William

P.S. A "luxury" at this point would be if the user got a "end of record"
error message when they tried to click on the Next button but there were no
records left.


Nov 12 '05 #2
DFS
You left off the "Form" in your subform reference. It should be (dropping
brackets):

Forms.frmSearch .sfrmSearchResu lts.Form.Studen tID
"MGFoster" <me@privacy.com > wrote in message
news:tY******** **********@news read1.news.pas. earthlink.net.. .
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm assuming you have the frmDetails RecordSource property as:
tblStudents, correct? If so, you can change the RecordSource to an
SQL statement like this (watch out for line-wrap):

SELECT * FROM tblStudents WHERE StudentID =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID]

Then when the user clicks another record in the subform
sfrmSearchResul ts the form frmDetails will update to the correct
record. You may have to do a form Requery for frmDetails in the
sfrmSearchResul ts OnCurrent event procedure. E.g.:

Forms!frmDetail s.Requery

This means both forms should be visible to the user at the same time.

If there isn't a matching record in the tblStudents the frmDetails
will have empty controls. You can set the frmDetails OnCurrent event
to change the form's Title Bar like this:

Me.Caption = "Student ID: " & IIf(IsNull(Me!S tudentID), _
"No Record",Me!Stud entID)

This will tell the user if a record is present or not.

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP84rm4echKq OuFEgEQJBUgCeOG GrrqW0/BrIapd+I6M05oG0 qasAoOLv
c/0SEKbzFnUWHl5xO ItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResul ts]. The subform is bound to a query [qrySearchResult s]
that returns records based on criteria in the main form. The user then
double clicks a row on the datasheet subform to open yet another form
[frmDetails] bound to a table [tblStudents]. These two forms are linked by the [StudentID] field. So far so good.

Here' is where I'm stumped. I'd like to put a Next Record navigation button on the [frmDetails] form so the user can go to the next record of the query results listed in the datasheet form [sfrmSearchResul ts] instead of closing the form and going to the next record of the datasheet. Does anyone know the code for that? Here is what I've tried to no avail. I get a "compile error--expected array."

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Cli ck

DoCmd.GoToRecor d , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID])

Exit_cmdNext_Cl ick:
Exit Sub

Err_cmdNext_Cli ck:
MsgBox Err.Description
Resume Exit_cmdNext_Cl ick

End Sub

Thank you for any and all help.

William

P.S. A "luxury" at this point would be if the user got a "end of record" error message when they tried to click on the Next button but there were no records left.

Nov 12 '05 #3
Thanks MG.

I tried your code but no luck. It opened to the proper record, but when I
clicked next it went to a blank record. Also, although both forms are open,
I only want the frmDetails form, which is on top, to be the one the user
clicks the next button. Otherwise the way I have it is now, they have to
close
the Details form then go to the next record in the datasheet subform
[sfrmSearchResul ts] and doubleclick it to open the record in frmDetails.

William


"MGFoster" <me@privacy.com > wrote in message
news:tY******** **********@news read1.news.pas. earthlink.net.. .
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm assuming you have the frmDetails RecordSource property as:
tblStudents, correct? If so, you can change the RecordSource to an
SQL statement like this (watch out for line-wrap):

SELECT * FROM tblStudents WHERE StudentID =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID]

Then when the user clicks another record in the subform
sfrmSearchResul ts the form frmDetails will update to the correct
record. You may have to do a form Requery for frmDetails in the
sfrmSearchResul ts OnCurrent event procedure. E.g.:

Forms!frmDetail s.Requery

This means both forms should be visible to the user at the same time.

If there isn't a matching record in the tblStudents the frmDetails
will have empty controls. You can set the frmDetails OnCurrent event
to change the form's Title Bar like this:

Me.Caption = "Student ID: " & IIf(IsNull(Me!S tudentID), _
"No Record",Me!Stud entID)

This will tell the user if a record is present or not.

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP84rm4echKq OuFEgEQJBUgCeOG GrrqW0/BrIapd+I6M05oG0 qasAoOLv
c/0SEKbzFnUWHl5xO ItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResul ts]. The subform is bound to a query [qrySearchResult s]
that returns records based on criteria in the main form. The user then
double clicks a row on the datasheet subform to open yet another form
[frmDetails] bound to a table [tblStudents]. These two forms are linked by the [StudentID] field. So far so good.

Here' is where I'm stumped. I'd like to put a Next Record navigation button on the [frmDetails] form so the user can go to the next record of the query results listed in the datasheet form [sfrmSearchResul ts] instead of closing the form and going to the next record of the datasheet. Does anyone know the code for that? Here is what I've tried to no avail. I get a "compile error--expected array."

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Cli ck

DoCmd.GoToRecor d , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResul ts]![StudentID])

Exit_cmdNext_Cl ick:
Exit Sub

Err_cmdNext_Cli ck:
MsgBox Err.Description
Resume Exit_cmdNext_Cl ick

End Sub

Thank you for any and all help.

William

P.S. A "luxury" at this point would be if the user got a "end of record" error message when they tried to click on the Next button but there were no records left.


Nov 12 '05 #4

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

Similar topics

0
2156
by: Svelte Poshy | last post by:
I want to put a code in the control box with a picture of an arrow, imitating the right arrow in the foot of the form with which the user views the customers one after another. My form is a columnar form and has its source in the table customers.Also,when i come to the end of the records,i want to use a left arrow to go backwards till the beginning of the form. I suppose i must use the command Move Next ? But how shall i go back? And...
7
2402
by: todholt | last post by:
Hello, I am trying to bypass a form's automatic update, and instead call a stored procedure in sql server. I am using continuous forms. The problem I am having is with returning to the next selected record once I have performed the update. i.e. user edits record A and then clicks on record B. Record A is updated, and selection moves to record B. I don't know how to determine what record B is...
0
1758
by: Kaspa | last post by:
Hello, I have been trying to goto the next record once I update the subform. anybody knows how I can accomplish this. Thanks in advance. Kasparov
10
3352
by: giannis | last post by:
How can i know ("see") the next record using the BindingSource without move to the next record ?
1
2123
by: Tony Dunn | last post by:
I have inherited another developer's database (Access 2003) and with it a problem I'm struggling with. The problem is this. I have a parent-child form pair, which is populated by a table (the parent) and a query (the child). The two sources are linked by an identical unique number. The table populating the parent uses the number as primary key. The child table has no primary key so it can used one-to-many. Users add data through the form...
2
3219
by: bhipwell via AccessMonster.com | last post by:
I need to put a button that allows the user to move to the next record. On the form, I have a list of employees that are filtered by the company they work for. Obviously, if I use the simple Gotorecord command, it will pull up the next record regardless of what company that employee works for. So... 1) I need the button to take the user to the next record where the company (field is CompanyID) matches the company on the form.
1
2477
by: stuart | last post by:
I have a list of records in a subform that a user can either edit or delete. This is an unbound form. If the user deletes a record, I want to refresh the form, and then position the cursor on the next record on that subform. This seems like that this should be a fairly easy thing to accomplish, but I cannot get it to reposition the cursor on the next record. The following is my code segment: Any help would be greatly appreciated!!! ...
1
4272
by: Arli | last post by:
I have the following linked tables: tblMainPL is my main table that I need to pull the information in from. It has the following fields: Autonumber1 -PK set as autonumber Date - short date format-example: (10/22/08) Load Number -Number-Single (should not be higher than 35-40 per day) WorkOrder -Text- 50 (string of letters and numbers of varying length)-example-KR53103 2625000-48 Badge -text- (employee badge number)-example-c12345
8
6005
by: mfaisalwarraich | last post by:
Hi everybody, I want to carry over last values of a record to the next record on ms access form. I'm using the Allen Browne's following method: http://allenbrowne.com/ser-24.html but its not working. please tell me what should I do?
0
9568
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
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
10007
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
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
8831
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2805
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.