Change Form/Report Query Based on User Selection

I have a form and report based on a query.  I need to change the query
based on what the user selects on a form.  Using VBA in MS Access
2002, can I change a single field in an existing query from GROUP BY
to LAST? This process would be initiated by a click event on a form.
Thanks in advance for any help.
0
Wayne
12/7/2009 6:25:25 PM
access.queries 6343 articles. 1 followers. Follow

3 Replies
893 Views

Similar Articles

[PageSpeed] 27

I would say only if you are willing to construct the entire query string in 
VBA and then apply that string as the source of the report.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Wayne wrote:
> I have a form and report based on a query.  I need to change the query
> based on what the user selects on a form.  Using VBA in MS Access
> 2002, can I change a single field in an existing query from GROUP BY
> to LAST? This process would be initiated by a click event on a form.
> Thanks in advance for any help.
0
John
12/7/2009 8:04:12 PM
On Dec 7, 12:04=A0pm, John Spencer <spen...@chpdm.edu> wrote:
> I would say only if you are willing to construct the entire query string =
in
> VBA and then apply that string as the source of the report.
>
> John Spencer
> Access MVP 2002-2005, 2007-2009
> The Hilltop Institute
> University of Maryland Baltimore County
>
>
>
> Wayne wrote:
> > I have a form and report based on a query. =A0I need to change the quer=
y
> > based on what the user selects on a form. =A0Using VBA in MS Access
> > 2002, can I change a single field in an existing query from GROUP BY
> > to LAST? This process would be initiated by a click event on a form.
> > Thanks in advance for any help.- Hide quoted text -
>
> - Show quoted text -

Thanks. Putting the SQL into a string seems to be the best way to do
it but now I have a new problem.

When I change the query GROUP BY field to LAST in VBA the Control
Source name changes from ServiceFrom to LastOfServiceFrom.  On the
form I have tried many ways to display both fields like:

=3DIIf(IsError([LastOfServiceFrom]), [ServiceFrom],[LastOfServiceFrom])
This displays the [LastOfServiceFrom] correctly but gives an #ERROR
when the query is changed to the [ServiceFrom] field.

=3DIIf(IsError([ServiceFrom]),[LastOfServiceFrom],[ServiceFrom])
This displays the same as the above????  I thought it would be the
opposite but it=92s not. Only the [LastOfServiceFrom] displays
correctly. Weird.

How can I get both field names to display correctly in my form when
the Record Source query is changed?
0
Wayne
12/8/2009 6:58:06 PM
You could alias the name in the query you are building so the name is consistent.

SELECT Last(ServiceFrom) as ServiceStart
FROM SomeTable

SELECT ServiceFrom as ServiceStart
FROM SomeTable
GROUP BY ServiceFrom

There are other ways, but they tend to cause parameter prompts to occur.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Wayne wrote:
> On Dec 7, 12:04 pm, John Spencer <spen...@chpdm.edu> wrote:
>> I would say only if you are willing to construct the entire query string in
>> VBA and then apply that string as the source of the report.
>>
>> John Spencer
>> Access MVP 2002-2005, 2007-2009
>> The Hilltop Institute
>> University of Maryland Baltimore County
>>
>>
>>
>> Wayne wrote:
>>> I have a form and report based on a query.  I need to change the query
>>> based on what the user selects on a form.  Using VBA in MS Access
>>> 2002, can I change a single field in an existing query from GROUP BY
>>> to LAST? This process would be initiated by a click event on a form.
>>> Thanks in advance for any help.- Hide quoted text -
>> - Show quoted text -
> 
> Thanks. Putting the SQL into a string seems to be the best way to do
> it but now I have a new problem.
> 
> When I change the query GROUP BY field to LAST in VBA the Control
> Source name changes from ServiceFrom to LastOfServiceFrom.  On the
> form I have tried many ways to display both fields like:
> 
> =IIf(IsError([LastOfServiceFrom]), [ServiceFrom],[LastOfServiceFrom])
> This displays the [LastOfServiceFrom] correctly but gives an #ERROR
> when the query is changed to the [ServiceFrom] field.
> 
> =IIf(IsError([ServiceFrom]),[LastOfServiceFrom],[ServiceFrom])
> This displays the same as the above????  I thought it would be the
> opposite but it�s not. Only the [LastOfServiceFrom] displays
> correctly. Weird.
> 
> How can I get both field names to display correctly in my form when
> the Record Source query is changed?
0
John
12/8/2009 7:26:28 PM
Reply:

Similar Artilces:

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

how create sum function in form field
I'm trying to utilize the sum function in a field on an Outlook 2002 form. I want the form field to sum up the other form fields. Sum is not a function listed in the value tab. Please advise. ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

Duplicate copies of a report
page hi to all I have a report that needs about 4" of height for each record. When printed, I'd like 2 identical copies of the report to appear on the page separated by a dotted line. I'm new to reports, so I could use a few clues how to do this. Thank you Becky "Becky" <Becky@discussions.microsoft.com> wrote in message news:641290ED-CA04-415B-9680-2E3BCF40921C@microsoft.com... > page hi to all > I have a report that needs about 4" of height for each record. When > printed, I'd like 2 identical copies of the report to appear on the page &...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

Reports error 05-17-07
I have recently migrated our CRM database to a new SQL 2005 server. I have setup reportserver on the server which works fine. When accessing Reports in CRM, I get mixed results: On the CRM server, the report window opens fine but with no reports On the SQL server, I get an error message "ERROR: An error has occurred. For more information, contact your system administrator" On other PC's I get the same error message. Is this a CRM error or a Report services error? It is getting slightly confusing now. Many thanks, Neil Paddock. Since you migrated the reports have you ch...

Stop sheet showing when Using Datapig's Force Users to enable macr
Hi, I think this is probably not do-able I'm using Datapig Technologies example to force users to enable macros When the workbook is closed all sheets other than a warning sheet are very hidden so that if the workbook is opened with macros disabled then the user can only see a warning sheet saying to close and open with macros enabled. Then on opening with macros enabled the waring sheet is very hidden and the other sheets can be seen. Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.ScreenUpdating = False Sheets("Warning").Visible = True Sh...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin�cius Pitta...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

Taking the Mode based on cell value
Could you provide a few more details about what you want to do? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "sip8316" <sip8316@discussions.microsoft.com> wrote in message news:E3F4DE24-C5E8-4911-96E6-E61A1E56DEF0@microsoft.com... > ...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

Pass Through query with criteria on a form
I have a Pass Through query that looks like this. select Location,City,State,Country,Pings from (select sd_term_name_loc as 'Location', sd_term_city as 'City', sd_term_st as 'State', sd_term_cntry as 'Country', count(sd_key)as 'Pings' from detail (nolock) where -- ***** The dates below refer to the date and time at which the transaction was loaded to PRM. -- ***** -- ***** The number of pings which have occurred BETWEEN those dates/times will be counted. -- ***** -- ***** Enter the date/time in the format '09/16/2007 14:00:00.000...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

Should I change this code?
Should I change 556 to 560???..............Thanks for your help..........Bob Private Sub Command560_Click() On Error GoTo Err_Command556_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmClientInfomation" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command556_Click: Exit Sub Err_Command556_Click: MsgBox Err.Description Resume Exit_Command556_Click End Sub On Sun, 15 Jul 2007 16:37:26 +1200, "Bob V" <rjvance@ihug.co.nz> wrote: > >Should I change 556 to 560???..............Thanks for your help.....

Deleted User Mailbox
Delete a user from Exchange 2003 and the mailbox showed as orphane. Later created a new user and connected that mailbox to that new user successfully. Now the new user cannot logon using OWA. Under Mailboxes in the ESM it shows user connected successfully but under Last Logged in by it show ... S-1-5-21-106....... Please advise. Thank you in advance. ...

symbols won't work in form fields
I have Access 2002. We write a lot of letters in French and as I have a QWERTY keyboard, we have shortcuts for the french letters which are missing from the keyboard. For example Ctrl + e is e with an accute accent, Alt + e is e with a grave accent, and so on. It all works just fine in WORD. But in my forms in my ACCESS database, in my fill-in fields, the shortcuts simply don't work. And there is no "symbol" option available in the tool bar to insert a symbol or French character. Is there any way I can add this function in to the database ? thanks .. Roger ...

Prompted for password when running a report
Running CRm 3.0 on a single SBS 2003 box. Everything seems to work great except we get prompted for windows credentials when running a report. I verified the reports and reportserver website are using integrated authentication. The webserver is in the local intranet zone. Any ideas? Thanks Dave Dave, I'd first try adding the server as a 'trusted site' in IE, and under 'custom level' set User Authentication.Logon to "Automatic logon with current username and password". Hope that helps, Jeff Bennett CRM Practice Manager Solutions Consulting Group, Inc....

How to change default font in Outlook 2003
Can someone tell me how to change tthe default font in Outlook 2003 when composing a new email. It always comes up as Times New Roman. I remember somewhere that I specified that Outlook should use Word as the text editor and that seems to be the case. I have Arial as my default font in Word but this seems to make no difference when using Outlook. Hi, Please go to Tools > Setting > Mail Format > Stationery and Fonts > Fonts It's right there :) On 20 Nov 2005 06:28:45 -0800, amarsarit@gmail.com wrote: >Hi, >Please go to Tools > Setting > Mail Format > Statione...

icon changes with change of extension
when we change the extension of a file in windows, its icon also changes..... how does windows do tht. in my application i require a similar approach. i want the icon to be dependent on the file extension not on the attributes of the file. i have gone trough the registry but things are not very clear. Windows has listed all the file extensions avaliable there, but there is no general way to extract icons for those extension... kindly help icon changes with change of extension "Neelu" <nemesia31@gmail.com> wrote in message news:1161232739.720722.120950@b28g2000cwb.google...

Combo Box on Forms
Hi, I am using a combo box on a form that has several items w/ one being Other. If the user selects other I want them to be able to input what they want so that it will go into the table instead of just the "Other". I just am not really sure on how to do that. Can you help? Thanks, Jaime In design view click on VIEW - Properties and the the combo. Then change Limit To List to No. -- KARL DEWEY Build a little - Test a little "jseger22@yahoo.com" wrote: > Hi, > > I am using a combo box on a form that has several items w/ one being > Other. If the use...