473,594 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing query results in a form

1 New Member
Hello everyone.

I have Access 2000 database which holds student records in the school.It stores subject grades for each student.In the 'Student Grade Form', I would like to search student surname using a query rather than scrolling down through 100s of names.Also, I would like the results of the query search to show in the form automatically in fields of 'Student name' and 'Student surname' based on the results.Is there any way I can do this?Should I create a subform?

So far, I have created a query to find student name in a another form called 'Student Form', where query results show in a new form called: 'Query for form'.On this form,I have a button to go back to the 'Student Form'.

Thanks guys for your time and help.

Below, VBA code for three forms:

Form_Student grade

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command14_Click()
  4. On Error GoTo Err_Command14_Click
  5.  
  6.  
  7.     DoCmd.GoToRecord , , acPrevious
  8.  
  9. Exit_Command14_Click:
  10.     Exit Sub
  11.  
  12. Err_Command14_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_Command14_Click
  15.  
  16. End Sub
  17. Private Sub Command15_Click()
  18. On Error GoTo Err_Command15_Click
  19.  
  20.  
  21.     DoCmd.GoToRecord , , acNext
  22.  
  23. Exit_Command15_Click:
  24.     Exit Sub
  25.  
  26. Err_Command15_Click:
  27.     MsgBox Err.Description
  28.     Resume Exit_Command15_Click
  29.  
  30. End Sub
  31. Private Sub Command16_Click()
  32. On Error GoTo Err_Command16_Click
  33.  
  34.  
  35.     DoCmd.GoToRecord , , acNewRec
  36.  
  37. Exit_Command16_Click:
  38.     Exit Sub
  39.  
  40. Err_Command16_Click:
  41.     MsgBox Err.Description
  42.     Resume Exit_Command16_Click
  43.  
  44. End Sub
  45. Private Sub Command17_Click()
  46. On Error GoTo Err_Command17_Click
  47.  
  48.  
  49.     DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  50.     DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
  51.  
  52. Exit_Command17_Click:
  53.     Exit Sub
  54.  
  55. Err_Command17_Click:
  56.     MsgBox Err.Description
  57.     Resume Exit_Command17_Click
  58.  
  59. End Sub
  60. Private Sub Command18_Click()
  61. On Error GoTo Err_Command18_Click
  62.  
  63.  
  64.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  65.  
  66. Exit_Command18_Click:
  67.     Exit Sub
  68.  
  69. Err_Command18_Click:
  70.     MsgBox Err.Description
  71.     Resume Exit_Command18_Click
  72.  
  73. End Sub
  74.  
Form_Student

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command18_Click()
  4. On Error GoTo Err_Command18_Click
  5.  
  6.  
  7.     DoCmd.GoToRecord , , acNext
  8.  
  9. Exit_Command18_Click:
  10.     Exit Sub
  11.  
  12. Err_Command18_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_Command18_Click
  15.  
  16. End Sub
  17. Private Sub Command19_Click()
  18. On Error GoTo Err_Command19_Click
  19.  
  20.  
  21.     DoCmd.GoToRecord , , acPrevious
  22.  
  23. Exit_Command19_Click:
  24.     Exit Sub
  25.  
  26. Err_Command19_Click:
  27.     MsgBox Err.Description
  28.     Resume Exit_Command19_Click
  29.  
  30. End Sub
  31. Private Sub Command20_Click()
  32. On Error GoTo Err_Command20_Click
  33.  
  34.  
  35.     DoCmd.GoToRecord , , acNewRec
  36.  
  37. Exit_Command20_Click:
  38.     Exit Sub
  39.  
  40. Err_Command20_Click:
  41.     MsgBox Err.Description
  42.     Resume Exit_Command20_Click
  43.  
  44. End Sub
  45. Private Sub Command21_Click()
  46. On Error GoTo Err_Command21_Click
  47.  
  48.  
  49.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  50.  
  51. Exit_Command21_Click:
  52.     Exit Sub
  53.  
  54. Err_Command21_Click:
  55.     MsgBox Err.Description
  56.     Resume Exit_Command21_Click
  57.  
  58. End Sub
  59. Private Sub Command31_Click()
  60. On Error GoTo Err_Command31_Click
  61.  
  62.     Dim stDocName As String
  63.  
  64.     stDocName = "Search by student surname"
  65.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  66.  
  67. Exit_Command31_Click:
  68.     Exit Sub
  69.  
  70. Err_Command31_Click:
  71.     MsgBox Err.Description
  72.     Resume Exit_Command31_Click
  73.  
  74. End Sub
  75. Private Sub Command33_Click()
  76. On Error GoTo Err_Command33_Click
  77.  
  78.     Dim stDocName As String
  79.     Dim stLinkCriteria As String
  80.  
  81.     stDocName = "Query for form"
  82.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  83.  
  84. Exit_Command33_Click:
  85.     Exit Sub
  86.  
  87. Err_Command33_Click:
  88.     MsgBox Err.Description
  89.     Resume Exit_Command33_Click
  90.  
  91. End Sub
  92. Private Sub Command34_Click()
  93. On Error GoTo Err_Command34_Click
  94.  
  95.  
  96.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
  97.  
  98. Exit_Command34_Click:
  99.     Exit Sub
  100.  
  101. Err_Command34_Click:
  102.     MsgBox Err.Description
  103.     Resume Exit_Command34_Click
  104.  
  105. End Sub
  106.  

Form_Query for form

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command19_Click()
  4. On Error GoTo Err_Command19_Click
  5.  
  6.     Dim stDocName As String
  7.     Dim stLinkCriteria As String
  8.  
  9.     stDocName = "Student"
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  11.  
  12. Exit_Command19_Click:
  13.     Exit Sub
  14.  
  15. Err_Command19_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command19_Click
  18.  
  19. End Sub
Feb 27 '08 #1
1 2832
NeoPa
32,566 Recognized Expert Moderator MVP
Check out Example Filtering on a Form for help with this concept.
Feb 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3113
by: thomas goodwin | last post by:
I have a query which asks for a parameter value to execute it. To see the results I have to: a) click on the query -- the "Enter Parameter Value" window pops up. b) enter the parameter value c) look at results in datasheet view If I want to run the query again, I must d) click to close the datasheet view e) click on the query f) enter the parameter value
3
13949
by: auron | last post by:
Hi there, I have a really stupid and banal problem with showing the results of a MySQL query in PHP, preciselly with MySQL count() function that gives to a variable in PHP the result. NOTE: The problem here is PHP not MySQL, in MySQL everything works just fine. Here is the query that I wrote for getting the number of how much
2
3318
by: Timbo | last post by:
Hi there, I’m not used to working in VB and I think this situation calls for excactly that. I use Access 97 SR-2. My first table is a table containing all the Tickets I got. The field ”Ticket” is simply a ticket-number. I’ve made a form in which I am to choose an existing Ticket and write a description for it pluss other things. The description to these Tickets are stored in another table called ”LogBook”. I then made a query on all of...
10
6214
by: sesling | last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have used the following in the criteria section of the query for the operators to refine the search . However, the operators do not always remember how the clients name appears in the DB and we get several failed queries. To correct this, I created a form...
4
2992
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form with data from the database, allow the user to update it, and then display the form again with POST data. I can get the data out of the database and get the user updates back into the database, but how do I get the filled-out form back to the user...
1
4269
by: tomlebold | last post by:
Having problems displaying query results from combo boxes on a sub form, which is on the same form that is used to select criteria. This has always worked form me when displaying query results on another main and sub form. The requery on the sub form and refresh comands on the main form do not work when the form is first displayed and when the selection criteria is changed. Should I be doing a refresh and then repaint of the sub form. ...
7
2939
by: underground | last post by:
I have a problem that I've spent countless hours on and I'm more than certain this is a obviuos issue to an expert but I am still learning. I have a paging script that I have modified to display a certian amount of records per page. But when I click on the next link , no new result are displayed it keep displaying the same result. Here is a sample of the script <?php include('hdb.html'); ?> <?php // Get the search variable from URL ...
1
2672
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form designed to show the expiring contracts. To do this I use a straight forward query in my form's ON LOAD code strwhere = " BETWEEN #" & Now() & "# AND #" & DateAdd("m", 6, Now()) & "#" Set MyQueryDef = MyDatabase.CreateQueryDef("qryMattersQuery",...
1
1292
by: terrencenr | last post by:
I'm trying to post the results of a query on a form but the line I've put in bold is coming up. Now the query runs and the results are posted but displayed in the header of the box to insert my date this appears and not the option just saying rdate - Forms!A4Form!rdate SELECT Reservation.ResDate, Passenger.PassFName, Passenger.PassLName, Passenger.PassAddr, Passenger.PassCont, Reservation.ResStatus, Cancellation.CanReason FROM...
0
7941
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
7874
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
8368
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...
1
8000
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
6652
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
5738
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
5404
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
3854
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...
1
2383
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

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.