473,386 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Next Record in Query Results via Form

Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResults]. The subform is bound to a query [qrySearchResults]
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 [sfrmSearchResults] 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_Click

DoCmd.GoToRecord , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResults]![StudentID])

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

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 4724
-----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]![sfrmSearchResults]![StudentID]

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

Forms!frmDetails.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!StudentID), _
"No Record",Me!StudentID)

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/AwUBP84rm4echKqOuFEgEQJBUgCeOGGrrqW0/BrIapd+I6M05oG0qasAoOLv
c/0SEKbzFnUWHl5xOItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResults]. The subform is bound to a query [qrySearchResults]
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 [sfrmSearchResults] 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_Click

DoCmd.GoToRecord , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResults]![StudentID])

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

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.sfrmSearchResults.Form.StudentID
"MGFoster" <me@privacy.com> wrote in message
news:tY******************@newsread1.news.pas.earth link.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]![sfrmSearchResults]![StudentID]

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

Forms!frmDetails.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!StudentID), _
"No Record",Me!StudentID)

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/AwUBP84rm4echKqOuFEgEQJBUgCeOGGrrqW0/BrIapd+I6M05oG0qasAoOLv
c/0SEKbzFnUWHl5xOItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResults]. The subform is bound to a query [qrySearchResults]
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 [sfrmSearchResults] 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_Click

DoCmd.GoToRecord , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResults]![StudentID])

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

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
[sfrmSearchResults] and doubleclick it to open the record in frmDetails.

William


"MGFoster" <me@privacy.com> wrote in message
news:tY******************@newsread1.news.pas.earth link.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]![sfrmSearchResults]![StudentID]

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

Forms!frmDetails.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!StudentID), _
"No Record",Me!StudentID)

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/AwUBP84rm4echKqOuFEgEQJBUgCeOGGrrqW0/BrIapd+I6M05oG0qasAoOLv
c/0SEKbzFnUWHl5xOItZFrhf
=OHzo
-----END PGP SIGNATURE-----
William Wisnieski wrote:
Hello Everyone,

Access 2000,

I have a main unbound form [frmSearch] with a bound datasheet subform
[sfrmSearchResults]. The subform is bound to a query [qrySearchResults]
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 [sfrmSearchResults] 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_Click

DoCmd.GoToRecord , , acNext([StudentID] =
[Forms]![frmSearch]![sfrmSearchResults]![StudentID])

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

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
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...
7
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...
0
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
by: giannis | last post by:
How can i know ("see") the next record using the BindingSource without move to the next record ?
1
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...
2
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...
1
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...
1
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...
8
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...

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.