473,836 Members | 1,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refreshing rowsource of combobox on the fly in ms access 2007

99 New Member
I have a combobox on a form which has to change its rowsource at run time on the basis of a particular label selection.I have managed to do the same but the problem is that it takes time to requery the combobox.If the selection of the label changes, the combobox record points out to the same records as previous one.Only after click on other controls does the records are as expected.I have used this:
Expand|Select|Wrap|Line Numbers
  1. Me.cboOverdueID.Rowsource.Requery
  2. Me.Refresh
It would be great if the reocrd changes happen quicker.
Mar 3 '12 #1
7 7216
Stewart Ross
2,545 Recognized Expert Moderator Specialist
First, I doubt you need the Me.Refresh method call - assuming that the label change you refer to is in your own instance of the database. Refresh is only really necessary if other DB users have modified the records in the underlying recordset and you want the data in your form's recordset to match.

The requery is all you need to update the combo itself.

Second, the requery method may take some time if it is based on something complex - like a query that does a lot of calculation, say - or that has many thousands of rows. Combos don't often need complex recordsources, in which case a requery may run much faster than, say, requerying the recordsource of the form itself.

Perhaps if you posted more details of the SQL for the combo's recordsource and what is changing on the form we could assist you more.

Mar 3 '12 #2
99 New Member
here's one of the queries:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblWO.A_ID, tblLOCATIONS!Platform_ST & "-" & tblWO!A_ITEMNO AS ID, FormatDateTime([A_DATEOPEN],2) AS Raised, tblWO.A_PRIORITY AS P, tblWO.A_ManhrsEst AS hrs, tblWO.A_DESCR AS Descr, tblWO.A_DATEGOAL FROM tblLOCATIONS INNER JOIN tblWO ON tblLOCATIONS.Platform=tblWO.A_LOCATION WHERE (((tblWO.A_DATEGOAL)>=Now() Or (tblWO.A_DATEGOAL) Is Null) AND ((tblWO.A_COMPLETION)<>100) AND ((tblWO.A_MANCLOSE)=No) AND ((tblWO.A_LOCATION)>IIf(getasset()=" & "**ALL**" & "," & "a" & "," & "zz" & ") Or (tblWO.A_LOCATION)=getasset())) OR (((tblWO.A_DATEGOAL)>=Now() Or (tblWO.A_DATEGOAL) Is Null) AND ((tblWO.A_COMPLETION) Is Null) AND ((tblWO.A_MANCLOSE)=No) AND ((tblWO.A_LOCATION)>IIf(getasset()=" & "**ALL**" & "," & "a" & "," & "zz" & ") Or (tblWO.A_LOCATION)=getasset())) ORDER BY tblWO.A_PRIORITY, tblWO.A_ITEMNO
Mar 5 '12 #3
32,584 Recognized Expert Moderator MVP
Please see [code] Tags Must be Used before posting again.
Mar 5 '12 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
You have a complex WHERE clause in the rowsource of your combo, which will undoubtedly slow requery performance down. Breaking it into its components, you have:

Expand|Select|Wrap|Line Numbers
  1. (((tblWO.A_DATEGOAL)>=Now() Or 
  2. (tblWO.A_DATEGOAL) Is Null) AND 
  3. ((tblWO.A_COMPLETION)<>100) AND 
  4. ((tblWO.A_MANCLOSE)=No) AND 
  5. ((tblWO.A_LOCATION)>IIf(getasset()=" & "**ALL**" & "," & "a" & "," & "zz" & ") Or 
  6. (tblWO.A_LOCATION)=getasset())) OR 
  7. (((tblWO.A_DATEGOAL)>=Now() Or 
  8. (tblWO.A_DATEGOAL) Is Null) AND 
  9. ((tblWO.A_COMPLETION) Is Null) AND 
  10. ((tblWO.A_MANCLOSE)=No) AND 
  11. ((tblWO.A_LOCATION)>IIf(getasset()=" & "**ALL**" & "," & "a" & "," & "zz" & ") Or 
  12. (tblWO.A_LOCATION)=getasset()))
I would concentrate on simplifying these conditions. If you have to specify all this just for the combo to work correctly there is something amiss in the underlying logic for your form or the combo or both!

Ask yourself what does the combo really have to contain, where can you get it, and what conditions if any are required for that combo.

It is difficult to give more advice on this without seeing your application or knowing how your form is set up. As you have a detailed knowledge of your application you are better placed than we are to sort out these complex conditions.

Mar 5 '12 #5
32,584 Recognized Expert Moderator MVP
Furthermore, function calls within a WHERE clause should be avoided where possible. They can be very delaying.

You may find it easier to simplify if you get rid of all the pointless concatenations of literal strings. #1 below is much easier to work with than #2, and there is no possible benefit to writing code as #2 :

Ooops. It turns out I can't illustrate a better version for #1 as it makes absolutely no sense in SQL anyway. It is wholly faulty SQL and I'm surprised it could ever run.
  1. Expand|Select|Wrap|Line Numbers
    1. Impossible to make sense of
  2. Expand|Select|Wrap|Line Numbers
    1. ((tblWO.A_LOCATION)>IIf(getasset()=" & "**ALL**" & "," & "a" & "," & "zz" & ")

Clearly this turns out to be rubbish anyway, as in it isn't valid SQL, and I'm surprised you haven't got an error message to share with us instead of reports of delays.
Mar 5 '12 #6
99 New Member
Yes I did get error messages and change the query to the following and it works perfect:
Expand|Select|Wrap|Line Numbers
  1. Me.frmWOMAINSUBMENU.Form.RecordSource = "SELECT tblWO.A_ID, tblLOCATIONS!Platform_ST & ' - ' & tblWO!A_ITEMNO AS ID, FormatDateTime([A_DATEOPEN],2) AS Raised, tblWO.A_PRIORITY AS P, tblWO.A_ManhrsEst AS hrs, tblWO.A_DESCR AS Descr FROM tblLOCATIONS INNER JOIN tblWO ON tblLOCATIONS.Platform=tblWO.A_LOCATION WHERE (tblWO.A_COMPLETION <> 100 AND tblWO.A_MANCLOSE=0 AND (tblWO.A_LOCATION > IIf('" & GetAsset() & "'='**ALL**' ,'a', 'zz') Or tblWO.A_LOCATION ='" & GetAsset() & "') AND (tblWO.A_DATEGOAL < " & Format(Now, "\#mm\/dd\/yyyy hh\:nn\:ss\#") & ") OR (tblWO.A_COMPLETION Is Null AND tblWO.A_MANCLOSE=0 AND (IIf('" & GetAsset() & "'='**ALL**' ,'a', 'zz') Or tblWO.A_LOCATION= '" & GetAsset() & "')) AND (tblWO.A_DATEGOAL < " & Format(Now, "\#mm\/dd\/yyyy hh\:nn\:ss\#") & ") ) ORDER BY tblWO.A_PRIORITY, tblWO.A_ITEMNO"
Mar 6 '12 #7
32,584 Recognized Expert Moderator MVP
You posted SQL you knew didn't work, without even mentioning that, somewhat fundamental, fact. Nice.
Mar 6 '12 #8

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

Similar topics

by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same height as they were in previous versions or will they be the "ribbon" style that takes up a huge portion of the screen? Also when I use Access 2007 to open an Access 2003 database that has custom menu bars they display as they did in Access...
by: ARC | last post by:
Just curious if anyone is having issues with Acc 2007 once the number of objects and complexity increases? I have a fairly large app, with many linked tables, 100's of forms, queries, reports, and lots of vba code. I'm nearly finished with re-doing my app in access 2007, and just imported an add-in program, which has added even more forms, queries and linked tables. Every so often now, after opening many different screens, I'll...
by: tony.abbitt | last post by:
I have recently installed Office 2007 (SP1) retaining the previous installation of Office 2003. I have converted an Access 2003 database to Access 2007. The database contains the VBA code 'DoCmd.RunCommand acCmdLinkTables' to initiate the dialog box to rebuild links to tables held in a back-end Access database (which has also been converted from Access 2003 to Access 2007). The code runs without problem in the original Access 2003...
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd like to know is the stability, speed & ease of use of both the products. I believe Access 2007 has a new file format too and that it may be slower.
by: Jim Mandala | last post by:
I had a user that converted an application from Access 2003 to Access 2007. The application is split front-end/backj end. When trying to open certain forms, the front end reportst that they don't have read permissions on the table. Neverthess, it is possible to actually open (and read the table directly while still in the front end. We fixed the References (I think) and ran compact and repair on both the front end and back end. Any...
by: jerken | last post by:
Im working in Access 2007 using two Combo boxes to select a category then product type. I am trying to get a couple fields to be displayed based on what the values are in the combo boxes. I have the boxes properly synchronized and working fine. Is there like a submit button I can input or a an after update I can create? I have been searching online and I cannot find anything. here is the code i have for the boxes. there are a couple...
by: simulationguy | last post by:
I have a database the runs fine in Access 2003 but this routine crashes with error 2105 "You can't go to the specified record" in Access 2007 on the last line !itemNumber.SetFocus Any idea why its different in 2007 or if there is a work around? I tried moving the .SetFocus line out of the With statement but same result. With Forms!frmMain!frmSKUInput.Form !WhichSKUCombo.Value = "" !WhichSKUList.Value = "" .RecordSource =...
by: simulationguy | last post by:
I inherited an Access 2003 database runs fine in 2003 but in 2007 I get an error on updating a form. Record Not available on the last statement !ItemNumber.SetFocus Does anyone know why Access 2007 is different and any clues on how to get it to work? With Forms!frmMain!frmSKUInput.Form !WhichSKUCombo.Value = "" !WhichSKUList.Value = "" .RecordSource = strSQL1
by: Jane Alford | last post by:
I apologise in advance if my previous question has got itself held up in a queue, but there's been no sign of it for over 3 hours now... I have a MAJOR problem, that I'm sure has a simple solution, but I've been hitting my head against this particular "brick" wall too often and I need to find a solution. I create a form, with a combination of text boxes and combo boxes. All the Add/Edit/Delete options for the form and fields are set to...
by: hype261 | last post by:
So I have done a bunch of work with the ribbon control in Access 2007 and I know I can put in callbacks for a combo box so that its values will be created at runtime when the ribbon is first loaded. I was wondering if there was any way to get the combo box to requery once it is loaded. Has anybody tried this before?
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...
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,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
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,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
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();...
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...

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.