Return The Query Results On The Form

Sep 13, 2005

Hi,
I am not much familiar with VB Coding.Can any body please help me with this Please:When i click on submit button,it has to show the query results on the Form.Please find the below code:

Private Sub Command_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Set db = CurrentDb
strSql = "SELECT Interface.[Interface ID], Interface.[Interface Name] from [Interface]"
Set rs = db.OpenRecordset(strSql)

Do While Not rs.EOF
Debug.Print ("Interface ID: " & rs![Interface ID] & "Interface Name: " & rs![Interface Name])
rs.MoveNext
Loop
rs.Close
db.Close
End Sub

#######################
It is not retrieving any thing.IF my code is wrong,Please advice me with the necessary steps to view the results on the form,when we clicl on the submit button.
Thanks,
Kanuri

View Replies


ADVERTISEMENT

Forms :: Query From Form To Return All Results

Jan 6, 2014

I have a form that displays multiple records in datasheet view. I want to query off of that form and return all results for all records being displayed. However, I'm not sure how to tell Access to do this. Access instead wants to return records for only the first displayed record in the form or the record that is highlighted by the cursor.

In the attached image you can see a list of AccountingUnits (AU) going down. My query using AU from the form as criteria will only return records for AU 114510 since it is the first record, but I would like to see records for all AU's being displayed by the form. How can I do this?

View 13 Replies View Related

Query Needs To Return Match And Unmatched Results

Jul 27, 2006

I have a query pulling data from several tables. In the middle I've got join between a part number in a BOM table and a part number in an inventory table.

What I want is the query to return the inventory location when we have stock. When we have nothing in, then there would be no entry in the inventory table and it should return a blank or null in this and all the proceeding tables.

Can this be done?

View 3 Replies View Related

Modules & VBA :: Return Results Of SQL Server Query To Access

May 28, 2014

I have an Access 2010 application that talks to SQL Server. Part of the application creates tables on the SQl Server and inserts data to it (I know SQL Server has its on data inport/export wizard and bulk insert capabilities but for reasons outside of my control it needs to be done from Access). So I have a connection to the SQl Server and i have VBA that happily executs SQL statements on the SQl Server. The problem is I want to return a recordset from the result of a SQL query issued to the SQL Server. The idea being to check for the presence of tables already created, and if so, append to the already existing table, otherwise if it does not exist, create it and insert data to it.Ive tried the following code but it seems no recordset is being returned:

Set objConnection = New ADODB.Connection
objConnection.Open "DRIVER={SQL Server};SERVER=10.200.3.14;trusted_connection=yes; DATABASE=" & Me.Combo54
strSQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = '" & Me.Combo54 & "'"
strSQL = "USE " & Me.Combo54 & " " & strSQL
Set Rst = cmd.Execute("USE " & Me.Combo54 & " " & strSQL)

View 1 Replies View Related

Return Weekend Results On Monday, Yesterday's Results Otherwise

Nov 14, 2007

I am trying to filter a form to show the entire weekend's activity on Monday but only yesterday's activity Tuesday through Friday. Using this code I can return Friday's results on Monday and yesterday's for the rest. How do I get the range Friday to Sunday?

IIf(DatePart("w",Now())=2,Date()-3,Date()-1)

Using >Date()-3 doesn't work.

Thanks

Bruce

View 5 Replies View Related

Return Results Where There Is No Relationship

Aug 4, 2006

Hi all,

I have two tables: ImageSoft and Software.

All items of software which have a type SA (Standard Application) must have an entry in ImageSoft under every Image Code.

When I add a new software title of type SA, it won't be included in ImageSoft for every Image Code and as I have a lot Image Codes I'd like to automate the addition of these new software items to the ImageSoft Table.

If I do a query with three fields: ImageSoft!ImageCode, Software!SoftwareCode and Software!Type, where Type was the criteria of "SA", the query returns the results of all the items that are already in ImageSoft and not those that aren't. Is there a way to return all those that are not in ImageSoft and not return those that are? I can the use these results to append them to the ImageSoft table and therefore ensure that all type SA software items are matched with each Image Code in ImageSoft.

Cheers,

Matt

View 9 Replies View Related

Help To Return Results In A Certain Order

Oct 23, 2006

Hi,

i would like to return information in the below format but not very sure how it is to be done.

Role, Name, ID, Contact Number
Z, Mary, 05, 1234567
, Matt, 02, 2233445
A, Bob, 10, 7654321
C, Tammy, 11, 9988776

and the order of Role (Z,A,C) is fixed it has to be in this order and if Role Z has more than one person, it will return only the name, id and contact number but will not repeat the role.

View 1 Replies View Related

Return Listbox Results On Double Click

Jun 2, 2005

This is probably failry simple if you know what you're doing, but I don't know what I'm doing....

I have a form (Purchase Orders) and on that form there is a search button to allow the user to search the customers table by customer name. When the user clicks the search button a search form opens and the search results (customer number, first name, last name) populate a list box named "lstCustInfo". How can I set the list box double click event to return the customer number, first name and last name to the Purchase Orders form? To make it even more complex I would like to return the data in two fields: customer number and LastName, FirstName. The problem with returning the results in two fields though is that I need to be able to break it into three to save it in the customers table because the table has a place for Customer Number, First Name and Last name.

Does anyone have any suggestions? Is there a better way to do this than returning 2 fields and having to break it back into 3 to store?

View 6 Replies View Related

Queries :: Return Results That Exactly Match Criteria

May 9, 2013

I have 3 main tables: tblEmployees, tblJobs, and tblProcedures. (See attachment for relationship diagram and additional supplemental tables).A job can have multiple procedures and an employee can have multiple procedures too.

I need to write a query such that when searching by a specific job I can see all of the employees who are qualified for that job. This is done by seeing which employees have the procedures that belong to a job. But here's the catch: since a job can have multiple procedures, if an employee only has some of the procedures I don't want that particular employee to return as a search result. The employee must have ALL the procedures that belong to the selected job.

So for instance if I have:

tblJobs
Job1
tblEmployees
Emloyee1
Employee2

[code]...

If I search by Job1, I want only Employee2 to return as a result, NOT Employee1.I am at a lost for how to construct the SQL for something like that.

View 4 Replies View Related

Return Multiple Results Based On A Field

Aug 27, 2015

Event#
EID
Arrived Time
Code
Cancelled Time

[code]...

I need to find all EIDs where the Code is 611 where an Event# starting with F was Cancelled along with the time of the cancellation. For these results I also need the Arrived Time for the Event# starting with E for that EID.For instance, a result I'm looking for would be:

EID
Event# (F)
Cancelled Time
Event# (E)
Arrived Time

[code]...

View 1 Replies View Related

Modules & VBA :: Return Rows In Query From Variant Array Return From UDF

Sep 16, 2014

I have a simple UDF that takes a string and returns a variant, which is an array of strings Example Input "Brick Wall" Return value would be a variant array with first element "Brick" and and second element "Wall" Now I have a table with a field of strings, and I want to make a query that returns all the results from the function, one per line.

So if my input table looks like this

[strField]
"kick the ball"
"return the pass"

my query result should looks like this

[Orig] [new]
"kick the ball" "kick"
"kick the ball" "the"
"kick the ball" "ball"
"return the pass" "return"
"return the pass" "the"
"return the pass" "pass"

Last time I had to do something like this I used VBA exclusively, with ADO objects, but I thought a query based solution would be easier.

With my current data the largest return array size my function returns is 27 elements but I wouldn't want to rely on that number being fixed.

View 3 Replies View Related

Form And Query Return Different Recordsets

Dec 11, 2012

Is there a common answer or design mistake that would cause a form to return a different (much higher) record set than that if the query is ran by itself. The query is the control source for the form.

View 3 Replies View Related

How To Return Specific Rows In A Query To A Form

Dec 31, 2012

I have a Query of dates and I need to have those dates return onto a from horizontally?

View 1 Replies View Related

Trying To Use A Form To Return Multiple Fields From A Query

Nov 3, 2014

I have already made a query with all the information needed. What I am trying to do is create a form where a user can open the database and enter a unique number and have information from 10 fields associated with that number show.

View 5 Replies View Related

Form And Query To Return Records Between Certain Date Range

Oct 15, 2013

First, I am trying to get a query to return records between a certain date range. In the form I have DateFrom and DateTo unbound text boxes from which faculty select the date range. I know I have done this before, but I cant figure out how to create a field name and write the criteria for the source query in design mode!

I tried [Form]![FormName]![DateFrom]<[Form]![FormName]![DateTo] in the criteria but I can't seem to write a valid field name that doesn't alter the criteria in some way...

Second, in the same form, faculty enter the StudentID for the student they wish to get records for. How do I write the code to show a msgbox when there is no such ID in the event they enter an StudentID incorrectly.

View 1 Replies View Related

Query To Return Default Set Of Values In A Subform When Main Form Opens

Apr 23, 2007

Here is my sample DBA

I'd like to solve this issue

when I open my Quotations form I'd like a set of services to be selected by default, ex: Brush and Pen. So the user only has to input the quote amount

is there anyway to have the form open with a script like:
"on open (or on load). in subform SELECT refproduct where product from tblproducts = 1 and also SELECT refproduct where product from tblproducts = 4"
Therefore when my main form opens, in the subform I have already Brush on the 1st line selected and pen on the 2nd. My user only has to type the price.

Thanks for your much appreciated help

View 2 Replies View Related

Modules & VBA :: Return A Value From A Separate Query / Have To Show Up In A Field On Main Form

Jun 28, 2013

I want to return a value from a separate query and have that show up in a field on my main form. The field name from the query is "Six Month Date" and the query name is "DT6Monthqry". I want to return the value displayed in the"Six Month Date" from the query, matching the CustomerID in the query result to the CustomerID that is being displayed on the main form. The CustomerID is a text field.This is the code I placed in the Control Source property for the field I want to be displayed on the main form:

=DLookUp("[Six Month Date]","DT6Monthqry","CustomerID=" & [CustomerID])

The result of this displays a flashing "Error" in the field, even when I go to a Customer that I know has a result in the "DT6Monthqry".

View 8 Replies View Related

IIF Not Returning Data - If "false", Should Return All Results

Dec 29, 2006

Greetings,
I've been banging my head on this for days, and what really makes this difficult is the number of websites which say it should work just fine!

I'm working with Access 2003 and trying to make use of the IIf function. I have given my fields generic names in the examples below.

I have a number of items I want to search upon in my search form. Each item has a check box and a combo box. I want the query to look at the check box. If the box is checked, I want the query to use the value in the combo box. If the check box is UN checked, I want the query to ignore this field and return all values. I thought this was simple, until I tried to do it!

Here is my code, placed in the Field-name criteria box of the query:

IIf([Forms]![form-name]![checkbox-name]=True,[Forms]![form-name]![combobox-name])

Now I know that the function works, because I can manually add a value:

IIf([Forms]![form-name]![checkbox-name]=True,[Forms]![form-name]![combobox-name],2)

This will return all records where Field-name = 2.

So... my original code should work! Because no "false" condition is stated, the query should be blank, and should return all records. But it doesn't! Truly maddening.

Here are some attempts which did not work:

IIf([Forms]![form-name]![checkbox-name]=True,[Forms]![form-name]![combobox-name],>0)
---> The ">0" caused an error. In fact, I can only specify an integer - all else, including things with operators, do not work.

Working with nulls - it does not seem to recognize an unchecked box as a null.

That's the short version of the story - any and all ideas welcome!

Regards,
-- Mark

View 14 Replies View Related

Displaying Query Results In A Form...

Jun 17, 2006

I have created a Query to search for clients in my database, the query and the search all work fine, however it would be nice to have the query post the results into a form I have created to display clients data rather than posting the results in a tables view.

Is there anyway todo this?

Thanks in advance.

View 1 Replies View Related

How To Open Results Of A Query In A Form?

Apr 17, 2007

Hello. I have a problem which has me stymied. I have created a Query-by-Form in which the criteria for the query is two combo boxes. I had no problems setting that up, but I want to display the results of this query in another form. I know this is possible, but do I need code for this? Any help/suggestions would be greatly appreciated!

View 3 Replies View Related

Fill Form With Query Results

Feb 24, 2005

In the attached db (both 2K and 97 ver) there is one form. Fill in the Date with 12/01/04 and the Start with 12/01/04 and Stop with 12/31/04. Press the Run Query button. The query is displayed...

How can I do it so on button press the form is filled with the query results?

View 1 Replies View Related

Displaying Query Results In Form

Sep 13, 2006

Forgive me for what may sound like a dum question -- Access is completely new to me.

I have my table. I have this displayed as a form.

At the bottom of the form, I have a text box and a command button.

The user enters in a key value. The command button triggers a macro that runs a query.

Now, I'd like the form to display the data returned from the query. How?

I tried creating a new form with its Record Source set to the query. I had the macro close the original form, run the query and open the new form. But before the new form could be opened, Access prompted me for a 'parameter value' (I assume so that the query could be run again).

What am I doing wrong?

View 3 Replies View Related

Displaying Results Of SQL Query On Form

Dec 15, 2006

I searched the archives and Access Help and couldn't quite find the answer to this question, which is no doubt simple.

I have a form showing Projects with an embedded subform showing all the Buildings associated with a given project. In the form footer section of the subform, I would like to display summary information about the buildings in the project being displayed, such as count of buildings, count of residential buildings, count of commercial buildings, and so on, and I would like these summary values to update as users add or change building information.

I know how to write the SQL query to pull this information, but do I use a text box or some other vehicle to do this? Using a text box as a calculated control, I was able to produce the count of buildings using:

= COUNT([UnitID])

To get the count of residential buildings, I need to be able to specify "WHERE bldgtypeID = 'R'"...I can't get the text box to display results of an SQL statement. Can text boxes handle SQL statements?

I really appreciate any suggestions you have.

View 10 Replies View Related

Transferring Query Results From One Form To Another

Aug 27, 2004

I have one table of records that I would like to query and display the results.
I have created a form that asks the user for criteria for the query (search).
Then I want to display the results from that query in another form (results).
The problem is that I cannot figure out how to do it.

The results form is using the query as its source. I have tried running the
search and then opening the results form, but I get a message saying that
I tried to lock the table but it was in use.

Is there a way to link these forms so that i can bring up the search form,
perform the search, and have the results brought up in the results form?

Thanks for the help.

View 4 Replies View Related

Form Using Dynamic Query Results

Apr 29, 2006

Hi, hope this is a reasonable thing for semi-beginner to intermediate person to do.

Our MS Access 2000 db shared on a server stores projects, categories of projects, clients, contractors doing the projects. Contractors are offered projects within their chosen categories based on their order on the list (last company who was offered a contract goes to bottom of list, like that).

Currently we print out a phone list of the contractors (in desc. date order of the most recent offer accepted or refused), then we phone down the list until someone accepts. Later we enter all those offers in order on frmOffers to store the date & time stamp of that offer.

Problem is, several contracts can be on offer on a given day, so when a company accepts/declines Project A, that company is still showing as high on the (paper) list for Project B. So when we have 3 people phoning they don't know they've offered multiple contracts to the same company this morning.

Is it possible for a form "Offers" to be based on a query that keeps updating like that? For example, you open frmProject to display details of a certain Project, cmd button to open frmOffers (continuous form, showing all offers so far with company, phone #, "accept"/"decline" & date/time stamp). Then, when you tab to the next record, can you have it show which company is next in line (even as the person beside you has updated their frmOffers in the meantime)?

Would you need to have a separate table storing only the most recent offer for each company? If so, how would you get that updated all the time?

Anything you could offer to point me in the right direction would be very much appreciated!!

Thanks,

View 1 Replies View Related

Displaying Query Results In A Form

Feb 26, 2008

Hi everyone,

I have a query which totals the amount of all invoices for a specific project number. I would like to take this total and have it displayed on the form from where overall project information is inputed.

Right now I have a table which shows general project information and a table showing invoice infomation (linked to the general table via a project #)

I also have two forms, one for general info and there's a button which opens the invoice form. When the invoice form opens, it opens an invoice with the corresponding project number shown on the general form. I would like the total invoice amount (from the query) displayed on the corresponding general form.

ex: in the general form for project# 100, I click invoice once and enter $50, I click invoice again and enter $100. The query automatically shows a total of $150 for project# 100. I would like this $150 displayed on the general form for quick reference.

Thanks for all the help

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved