473,396 Members | 1,940 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,396 software developers and data experts.

Passing Query Results to Form

Maybe I am going about this totally wrong....

What I have written is a query pulling SSN, Student-ID, LastName,
FirstName, MiddleInitital from a table.

Sort is so LastName, FirstName, MiddleInitial, SSN, and StudentID are
all ascending, and in this order.

I want to the person using this query, in a ListBox, to be able to
look up a person (student) by last name to see if they are in the
table already, and then pass all the above information to the form, of
which this listbox is a part of.

How do I do this? I can only pass all information if I use a list box
based on the table, but as a result, I cannot make a listbox with the
students sorted alphabetically by last name.

Help! I am also a novice, so again, step by step - and thanks!
Nov 12 '05 #1
3 2600
Sami wrote:
Maybe I am going about this totally wrong....

What I have written is a query pulling SSN, Student-ID, LastName,
FirstName, MiddleInitital from a table.

Sort is so LastName, FirstName, MiddleInitial, SSN, and StudentID are
all ascending, and in this order.

I want to the person using this query, in a ListBox, to be able to
look up a person (student) by last name to see if they are in the
table already, and then pass all the above information to the form, of
which this listbox is a part of.

How do I do this? I can only pass all information if I use a list box
based on the table, but as a result, I cannot make a listbox with the
students sorted alphabetically by last name.

Help! I am also a novice, so again, step by step - and thanks!


In the listbox (lets' call it List0) AfterUpdate event you could do
something similar to this. Assumes The first column is the StudendID and
is hidden and the form is bound to the student table

Sub List0_AfterUpdate
Dim rst As DAO, .Recordset
Set rst = Me.recordsetclone
rst.FindFirst "StudentID = " & Me.List0
Me.bookmark = rst.bookmark
set rst = nothing
end sub

As the person selects a name, the after update event is called, looks for
the employee record, finds it, and displays it.

Nov 12 '05 #2
Hi, if this works, great - but how would I do this? I have no idea
where I would begin for such a thing. Thanks.

On Thu, 19 Feb 2004 06:34:49 GMT, Salad <oi*@vinegar.com> wrote:
Sami wrote:
Maybe I am going about this totally wrong....

What I have written is a query pulling SSN, Student-ID, LastName,
FirstName, MiddleInitital from a table.

Sort is so LastName, FirstName, MiddleInitial, SSN, and StudentID are
all ascending, and in this order.

I want to the person using this query, in a ListBox, to be able to
look up a person (student) by last name to see if they are in the
table already, and then pass all the above information to the form, of
which this listbox is a part of.

How do I do this? I can only pass all information if I use a list box
based on the table, but as a result, I cannot make a listbox with the
students sorted alphabetically by last name.

Help! I am also a novice, so again, step by step - and thanks!


In the listbox (lets' call it List0) AfterUpdate event you could do
something similar to this. Assumes The first column is the StudendID and
is hidden and the form is bound to the student table

Sub List0_AfterUpdate
Dim rst As DAO, .Recordset
Set rst = Me.recordsetclone
rst.FindFirst "StudentID = " & Me.List0
Me.bookmark = rst.bookmark
set rst = nothing
end sub

As the person selects a name, the after update event is called, looks for
the employee record, finds it, and displays it.


Nov 12 '05 #3
Sami wrote:
Hi, if this works, great - but how would I do this? I have no idea
where I would begin for such a thing. Thanks.
Well. I assume you created a form for students, perhaps via the Form Wizard.
If so, your form is linked (bound) to the Students table or to a query that
displays student records. Then I assume you have a list box to the left or
right of the student data that contains the student names. If you are with me
so far then dbl-click on the listbox to pull up the property sheet. Click on
the Events tab and then select the OnClick event, hit the triple dots and
paste the code in.

Change the reference from List0 to whatever your listbox name is. Also, I
assume StudentID is the first col of the list box, hidden or visible or is the
bound field of the listbox

Should work.

Later on, you can open up the query and view the SQL code. Then copy that
code into the rowsource of the list box. Then you could put some checkboxes
over the listbox to display the sort order....by last first, ssn, etc. Then
when you click on the checkbox, you get the SQL, remove the order by, add the
new sort order, and maybe swap the field order so your listbox search is more
dynamic. Ex:

If Me.SortByName then Me.List0.rowsource = "Select LastName, FirstName,
StudentID, SSN From ....
If Me.SortBySSN Then Me.List0.RowSource = "Select SSN, LastName, FirstName,
StudentID From ..

By changing the row source, and a slight adjustment to the column widths this
could be very cool.



On Thu, 19 Feb 2004 06:34:49 GMT, Salad <oi*@vinegar.com> wrote:
Sami wrote:
Maybe I am going about this totally wrong....

What I have written is a query pulling SSN, Student-ID, LastName,
FirstName, MiddleInitital from a table.

Sort is so LastName, FirstName, MiddleInitial, SSN, and StudentID are
all ascending, and in this order.

I want to the person using this query, in a ListBox, to be able to
look up a person (student) by last name to see if they are in the
table already, and then pass all the above information to the form, of
which this listbox is a part of.

How do I do this? I can only pass all information if I use a list box
based on the table, but as a result, I cannot make a listbox with the
students sorted alphabetically by last name.

Help! I am also a novice, so again, step by step - and thanks!


In the listbox (lets' call it List0) AfterUpdate event you could do
something similar to this. Assumes The first column is the StudendID and
is hidden and the form is bound to the student table

Sub List0_AfterUpdate
Dim rst As DAO, .Recordset
Set rst = Me.recordsetclone
rst.FindFirst "StudentID = " & Me.List0
Me.bookmark = rst.bookmark
set rst = nothing
end sub

As the person selects a name, the after update event is called, looks for
the employee record, finds it, and displays it.


Nov 12 '05 #4

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

Similar topics

7
by: Mike | last post by:
I have to pass a date from a form to a report query. I have written a query that works fine when I execute from SQL view, But I dont know how to pass a value from the form to this query. SELECT...
2
by: Bob Sanderson | last post by:
I have a search form from which I hope to be able to select a record by field JobNumber and display it with an output form titled test.php <html> <head> <title>Job Database Search</title>...
2
by: dath | last post by:
Hi, Searched the forum and found a lot on passing form input to aquery but not the other way around. Here is the situation: I have a timesheet form based on a subform query that asks the...
3
by: Jahangir | last post by:
Dear Fellows, I m in in Access VB, and working on a small project. Problem is that In main form (called search )I have made a textbox name text34, and a search button, which responsiblity is...
81
by: ljungers | last post by:
Are the Action(s) in a Macro run in sequence? How would a OpenQuery pass it's results to a OpenForm that followed in the action list? For example I have a form #1 that contains a couple of text...
6
by: jej1216 | last post by:
I am trying to put together a PHP search page in which the user can select none, one, two, or three fields to search, and then the results php will build the SQL with dynamic where caluses to reflect...
1
by: rfr | last post by:
I have a need to use a single version of a Visitor Response Feedback Form on numerous HTML documents. Rather than have numerous versions of this, one on each HTML document, it makes more sense to...
3
hyperpau
by: hyperpau | last post by:
Hi there guys! I have a Form where there are three comboboxes. This comboboxes are used as references for the parameter of 3 fields in a query. when I hit a command button in my form, it opens...
2
by: milo1955 | last post by:
I have a form that passes a single variable via the GET function to a mysql databse query with the results paginated. The first page of the results work fine, but the link to the second page yields...
2
by: robtyketto | last post by:
Greetings, I have a form where a combo box is used to select a name and Id. Theses values are passed into a subform. However the query now returns 0 results. So I edited the query and hard...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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,...
0
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...
0
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...

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.