473,473 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Create 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 7199
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.

-Stewart
Mar 3 '12 #2
HiGu
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
NeoPa
32,556 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.

-Stewart
Mar 5 '12 #5
NeoPa
32,556 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
HiGu
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"
  2.  
Mar 6 '12 #7
NeoPa
32,556 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

27
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...
2
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...
6
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...
9
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...
1
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...
8
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...
0
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...
4
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...
7
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...
1
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. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.