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 Replies


ADVERTISEMENT

Displaying The Results Of A Dynamic Query

Feb 11, 2007

Hi, I'm building a form where the user can choose various options to build up the query they want. It's going to be easier this way because the different combinations they might want would mean me writing well over 100 different queries. So I think I can build the sql statement in vb and then get a recordset back with the results, but the question is how to display it. I can't just assign the recordset to an existing form because the fields to be displayed will be different for different options. Ideally I'd like it to open just as if I had run:

DoCmd.OpenQuery <name of the query>

But it doesn't look like this is going to work for a query I've generated in the code, even if I use a querydef object (correct me if I'm wrong?). So does anyone know how I would go about doing this? (It would also be fine if the results appeared in a subform on the form I'm calling the query from, but I can't see how to do this either).

Any help gratefully appreciated.

Sim Bamford

View 2 Replies View Related

Outer Join Creating Duplicates In Dynamic Query Search Results

Jan 22, 2008

Now that i have read this again, i think it could be summed up into one question...if i have a form based off a query with an outer join that has various duplicate records, is there a way to use the recordset in an if statement that says something like if this recordID = that recordID then dont show one of them...hence not showing the duplicate field data in the form.If you want a more specific description of the problem, read on, otherwise don't read on.Hi All,So I hope I can explain this ok....here goes....I have a search using dynamic queries: I have a form where the user can put in various information he wants to search to find a record. In this case it is searching for Hotels. So the user can search a country to see all of the hotels in that country. Also, the user can search an interest like Beach or Nature to see those hotels that apply. Obviously each hotel may have more than one interest so I have a 1-many relationship with a table called Hotels_Interests.The kicker, and you can likely already see why, is that the user does not have to fill out every search field. He may search Country&Interest, or just one or the other, or leave everything blank to see all hotels in the database. The results are simply ordered by HotelID or something like that in a form that is based off the dynamic query. The dynamic query is of course just based off the query i explained, but with criteria added in.The problem is with the query that i am basing this search off of. Right now it has the main Hotels table as well as the 1-Many table Hotels_Interests and even another that is 1-Many Hotels_HotelTypes (say All Inclusive, Resort, etc.). So this query has various 1-Many tables as well as the main Hotels. Now, if i fill in all of those fields in the search form, there will obviously not be any duplicates returned, which is super. But if i leave Hotel_HotelTypes search field blank, i will be returned with the same hotel twice or more times, which is my problem, because i want nice search results.I have heard of people using Union queries to get rid of duplicates but this obviously does not solve my problem as i do not want to just get rid of these entries. What i think i want is some VBA method or whatever of showing in my search results each HotelID that meets the search criteria only one time.Right now i have it working with If statements that say if the user has left a specific search criteria blank then base the search off a different query. This is obviously crazy and is only a temp fix. Now that i want three or more 1-many tables in my query, i would be talking about if statements for like 6 or more queries, insane.I apologize for the length of this, but i wanted to be perfectly clear. I feel like it should be not too hard, like using a record set for the form and not showing certain records or something, but i am not sure how to do it.Thanks so much. Dillon

View 4 Replies View Related

Making A Dynamic Report From My Dynamic Form

Jun 30, 2006

I have a form that shows a list of all of my records in my database. I want to be able to click a button called "Report" and have that print a report that has all the records I have filtered on my form. I have a report in the format that i want it in, however, currently it prints every record and not just what is shown on my form. (The form is dynamic and I want the Report to be dynamically based on the form) HELP PLEASE!

View 6 Replies View Related

Dynamic Query And Record Source In A Form

Feb 23, 2005

I have Form A that has a combo box and a "Submit" button. When the user clicks on the Submit button it needs to open Form B. Recordsource of this Form B is "Query B"

Item selected on the combo box becomes the criteria for "Query B and Form B needs to be opened based on that criteria.

What is the easiest and fastest way (no dlookups please!) to do this?

If an illustration is possible through an example that will be wonderful.

Thanks in Advance.

View 1 Replies View Related

Queries :: Dynamic Query Based On A Form (ComboBox)

Jan 22, 2014

We have a ComboBox on a form with the months: Jan, Feb, Mar, Apr, etc.

We have fields in a budget table named: Jan, Feb, Mar, Apr, etc.

We want to create a query that pulls the correct field based on the value in the combo box.

This is what I have that doesn't work:

MyField: [Query1].[SumOf] & Forms![Main Menu]![test]

How to do this?

View 4 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

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 3 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

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

Complex Query/form Results Unexpected

May 16, 2006

I've got a query pulling data from a view I created that gives all the data I need. The query gets it's criteria from a form with 10 combo boxes, a radio box with 3 options and 2 date fields for the timeframe to run the report in.

The issue:
over half the columns of data that the radio buttons can limit results by have null values but only two of the columns are excluding records where the values in them are null. As any combination of the combo boxes are null I'm using the following format for my criteria per column
IIf(IsNull([Forms]![Margin Dialog]![InstallerOption]),[Installer_from_Web],[Forms]![Margin Dialog]![InstallerOption])
That is an example of a column that works, the following is a column that is excluding null values no matter what I do
IIf(IsNull([Forms]![Margin Dialog]![AOIOption]),[ProductType],[Forms]![Margin Dialog]![AOIOption])
I am not seeing the error and could use some thoughts.

View 13 Replies View Related

Pop Message In Form Based On Query Results

Jan 12, 2006

G'Day:

I have tried numerous things to try and create a pop up message or form to alert users of a timing conflict in a scheduling program.
I am not real familiar with codes and am not sure how to handle this.

I used Jason Browne's web site to help me construct a query that will list a result of time conflicts (ie some project is scheduled to occur before another one is completed).
What I need to have happen is the alert message or form opens when this conflict occurs but does nothing when the timing is ok.

I am not very familiar with code and am having a road block mentally. All help is appreciated!

THANKS

View 3 Replies View Related

Show Count Query Results On Form

Jan 24, 2006

I have a form that I am trying to show in a text box the results of a count query. The query has two fields in which one is a check box. The criteria for the text box field is set to true to list all that are checked. I want the query to show all the records that are true. This works if I run the query, but the result isn't showing in my text box on the form. On the form text box properties in Control source I have =DLookUp("[Run Number]","Control Room Drumctqry"). Run Number is the field that I am counting, Control Room Drumctqry is the query. Any idea as to what I am doing wrong?
Thanks,

View 7 Replies View Related

Show Count Query Results On Form

Jan 24, 2006

I have a form that I am trying to show in a text box the results of a count query. The query has two fields in which one is a check box. The criteria for the text box field is set to true to list all that are checked. I want the query to show all the records that are true. This works if I run the query, but the result isn't showing in my text box on the form. On the form text box properties in Control source I have =DLookUp("[Run Number]","Control Room Drumctqry"). Run Number is the field that I am counting, Control Room Drumctqry is the query. Any idea as to what I am doing wrong?
Thanks,

View 1 Replies View Related

Display Query Results On Form Via Text Box

Aug 27, 2004

Hi,
I have created a form (Form1) based on a table (Table1) and also a Query based on this table (Query1). I calculate a field in the query (Expr1: [column1] + [column2])
Now i have created a text box on Form1 that should display Expr1.
I know I could also calculate the value directly via the expression builder, but I would prefer to simply display Expr1 from my query. Which is the syntax I have to use in the Expression Builder?
I tried "= [Query1]![Expr1]" but it does not work.
Thanks for your help
Tigrou

View 3 Replies View Related

Forms :: Display Query Results In A Form

Jul 25, 2014

I am trying to allow end-users to only use buttons to navigate and display records in my database (so they don't know access is in the background) I have query that runs when they press a button but after they run it there is no way to get back to the main interface screen i.e. there is not a place to put another button and close the query. I was looking into creating a form to display the query results in datasheet view but it is not appearing the way I want. I inserted a subform and the results got better but I also do not like the way it displays because the user can see the subform, simple solution to get my data to display in the form so a user can view the results similar to datasheet view?

View 3 Replies View Related

Forms :: How To Sort Query Results With A Form

Aug 14, 2013

Essentially I have a table for rooms around my school and what the rooms contain. Most of the details for the rooms are Boolean (e.g. If the room has a projector, Yes/No).

So what I am trying to do is have a form where i can select a checkbox(s) and if i tick one, a query that holds all the room details will only show rooms with projectors in them, which i can then display those results in another form.

My question is how do I get the check boxes in the form to narrow down the room results to only show the ones with the criteria i have selected in the form?

View 1 Replies View Related

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

Display Query Results On User Form?

Dec 27, 2013

I have created form and would like to display query results on form (in textbox), which is executed based on combobox change event on the same form.

View 3 Replies View Related

Query In One Form With Results Displayed In Another Form

May 13, 2005

First, I am a beginner with Access. I am a graphics designer that has been assigned to cover for a db programmer that quit!

Here is my problem:

I have a database that we use to hold customer information. There are 22 fields in each record, and we are now well over 3000 records.

Once upon a time, to find a specific customer, we would just go to the bottom of the page, and use the arrow buttons to scroll through them all. This is no longer possible as the size is too big to manually search.

What I would like to do:

Upon Access startup, display a form that has a single input field and a button titled "Search". The input field is titled [UserName], as this field is the unique key identifier for the record. When the user types in the UserName and clicks the SEARCH command button, another form appears to display JUST THAT RECORD in the easy to read form!

If this is really basic, I appologize. I have 20 years experience with commercial illustration and only 7 days experience with Access. I have purchased books, and hit the forums, but I am not a VB programmer, and my skills this area are REAL weak!

My resourse books include the following:
Wiley - Access 2003 Bible [Prague, Irwin & Reardon]
Osbourne - How to do Everything with Access 2002 [Anderson]
O'Reilly - Access Cookbook [Getz, Litwin & Baron]

Thanks in advance for any assistance.

View 1 Replies View Related

Query Results In Form, But What If Query Is Null?

Aug 30, 2005

I have a query that displays results in a form, but if the query is null, I want to display a different form, or just an error message that says something like "your query returned no results" (right now it will display the form with no fields)

I am a beginning Access/VBA user and have searched and browsed the forum for combinations of null/query/form, but haven't found what I need. Can anyone point me in the right direction?

Thanks for any help.

View 5 Replies View Related

Filter Query Results By Date Range In Form

Jan 3, 2006

I have a query form that allows user to search by two criteria (in which, user can select "And" or "Or" clause for the two criteria). I also allow user to filter the results by date range. On the form, I have two command button, one will prompt the results in a query table, and the other will prompt a report.

Problem 1
I manage to prompt report with a date range (i.e. two unbound text boxes for start date and end date). But, I dont' manage to disable the filter if the date range is null. Below is the code for this report command button. Should I use a toggle button to make a select case?

Private Sub cmdReport_Click()
Dim varItem As Variant
Dim strDocName As String
Dim str1MainCate As String
Dim str2MainCate As String
Dim str2MainCateCondition As String
Dim strDate As String
Dim strSQL As String
Dim strFilter As String
' Build criteria string for 1st ComboBox
For Each varItem In Me.fstMainCate.ItemsSelected
str1MainCate = str1MainCate & ",'" & Me.fstMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str1MainCate) = 0 Then
str1MainCate = "Like '*'"
Else
str1MainCate = Right(str1MainCate, Len(str1MainCate) - 1)
str1MainCate = "IN(" & str1MainCate & ")"
End If
' Build criteria string for 2nd Combo Box
For Each varItem In Me.SecMainCate.ItemsSelected
str2MainCate = str2MainCate & ",'" & Me.SecMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str2MainCate) = 0 Then
str2MainCate = "Like '*'"
Else
str2MainCate = Right(str2MainCate, Len(str2MainCate) - 1)
str2MainCate = "IN(" & str2MainCate & ")"
End If
' Get 1toggle button condition
If Me.optAnd2MainCate.Value = True Then
str2MainCateCondition = " AND "
Else
str2MainCateCondition = " OR "
End If
' Build SQL statement
strSQL = " SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips " & _
"WHERE NewsClips.[1CategoryMain] " & str1MainCate & _
str2MainCateCondition & "NewsClips.[2CategoryMain] " & str2MainCate & ";"
' Build criteria string for Date
If Not IsNull(Me![dateTo]) Then
strDate = strDate & " NewsClips.IssueDate Between #" + Format(Me![datefrom], "mm/dd/yyyy") + "# AND #" & Format(Me![dateTo], "mm/dd/yyyy") & "#"
'Format(Me.dateTo, "mm/dd/yy")
Else
strDate = strDate & " NewsClips.IssueDate >= #" + Format(Me![datefrom], "mm/dd/yyyy") + "#"
End If
' filter string
strFilter = strDate
' Open report
strDocName = "RptCateDateQry"
DoCmd.OpenReport strDocName, acViewDesign, , strFilter
With Reports(strDocName)
.RecordSource = strSQL
.Filter = strFilter
.FilterOn = True
End With
DoCmd.Save acReport, strDocName
DoCmd.OpenReport strDocName, acViewPreview
Exit_cmdReport_Click:
End Sub

Problem 2
I have no idea how to filter the query results by date range in the query table. Below is the code of the query table button, which do not offer the filter feature. Would really appreciate it if you can give me some advice.

Private Sub cmdOK_Click()
On Error GoTo cmdOK_Click_Err
Dim blnQueryExists As Boolean
Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.View
Dim varItem As Variant
Dim strDate As String
Dim str1MainCate As String
Dim str2MainCate As String
Dim str1MainCateCondition As String
Dim str2MainCateCondition As String
Dim strSQL As String
' Check for the existence of the stored query
blnQueryExists = False
Set cat.ActiveConnection = CurrentProject.Connection
For Each qry In cat.Views
If qry.Name = "QryCateDateForm" Then
blnQueryExists = True
Exit For
End If
Next qry
' Create the query if it does not already exist
If blnQueryExists = False Then
cmd.CommandText = "SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips"
cat.Views.Append "QryCateDateForm", cmd
End If
Application.RefreshDatabaseWindow
' Turn off screen updating
DoCmd.Echo False
' Close the query if it is already open
If SysCmd(acSysCmdGetObjectState, acQuery, "QryCateDateForm") = acObjStateOpen Then
DoCmd.Close acQuery, "QryCateDateForm"
End If
' Build criteria string for Date
If Not IsNull(Me![dateTo]) Then
strDate = strDate & " NewsClips.IssueDate Between #" + Format(Me![datefrom], "mm/dd/yyyy") + "# AND #" & Format(Me![dateTo], "mm/dd/yyyy") & "#"
'Format(Me.textStartDate, "mm/dd/yy")
Else
strDate = strDate & " NewsClips.IssueDate >= #" + Format(Me![datefrom], "mm/dd/yyyy") + "#"
End If

' Build criteria string for 1MainCate
For Each varItem In Me.fstMainCate.ItemsSelected
str1MainCate = str1MainCate & ",'" & Me.fstMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str1MainCate) = 0 Then
str1MainCate = "Like '*'"
Else
str1MainCate = Right(str1MainCate, Len(str1MainCate) - 1)
str1MainCate = "IN(" & str1MainCate & ")"
End If
' Build criteria string for 2MainCate
For Each varItem In Me.SecMainCate.ItemsSelected
str2MainCate = str2MainCate & ",'" & Me.SecMainCate.ItemData(varItem) & "'"
Next varItem
If Len(str2MainCate) = 0 Then
str2MainCate = "Like '*'"
Else
str2MainCate = Right(str2MainCate, Len(str2MainCate) - 1)
str2MainCate = "IN(" & str2MainCate & ")"
End If
' Get 1MainCate condition
If Me.optAnd1MainCate.Value = True Then
str1MainCateCondition = " AND "
Else
str1MainCateCondition = " OR "
End If
' Get 2MainCate condition
If Me.optAnd2MainCate.Value = True Then
str2MainCateCondition = " AND "
Else
str2MainCateCondition = " OR "
End If
' Build SQL statement
strSQL = " SELECT NewsClips.IssueDate, NewsClips.Title_Eng, NewsClips.Titile_Chi, NewsClips.NewsSource, NewsClips.[1CategoryMain], NewsClips.[1Sub-Category], NewsClips.[2CategoryMain], NewsClips.[2Sub-Category], NewsClips.hyperlink, NewsClips.FirstTwoPara, NewsClips.Notes, NewsClips.attachment FROM NewsClips " & _
"WHERE NewsClips.[1CategoryMain] " & str1MainCate & _
str2MainCateCondition & "NewsClips.[2CategoryMain] " & str2MainCate & _
str1MainCateCondition & strDate & ";"
' Apply the SQL statement to the stored query
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Views("QryCateDateForm").Command
cmd.CommandText = strSQL
Set cat.Views("QryCateDateForm").Command = cmd
Set cat = Nothing
' Open the Query
DoCmd.OpenQuery "QryCateDateForm"

' If required the dialog can be closed at this point
' DoCmd.Close acForm, Me.Name
' Restore screen updating
cmdOK_Click_Exit:
DoCmd.Echo True
Exit Sub
cmdOK_Click_Err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Procedure: cmdOK_Click" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description:" & Err.Description _
, vbCritical, "Error"
Resume cmdOK_Click_Exit
End Sub


Sorry for posting this question again, as I thought it's better to make it a seperate posting, rather than a reply to my early post. Your advice will be greatly appreicated.

View 1 Replies View Related







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