473,671 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does requery on combobox callback function not requery?

13 New Member
I have a callback function that correctly fills a combobox (A) with two-column data on load. I have a second combobox (B) that acts as a filterchoice for the first. When the combobox B is updated, I have a AfterUpdate event to requery the combobox A. However, the process doe snot change a thing in combobox A. Watching the code run through I see the function correctly create the new array needed, but the function never goes to the acLBGetValue section to change the data.

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.     Dim chkitm As Variant
  4.     Dim ProvID As Integer
  5.     Dim rs_Provider As New ADODB.Recordset
  6.     Dim rs_Measure_Class As New ADODB.Recordset
  7.     Dim rs_Measure As New ADODB.Recordset
  8.     Dim rs_OPPE As New ADODB.Recordset
  9.     Dim FilterCrit As String
  10.  
  11.     Dim DWConn As New ADODB.Connection
  12.     Dim strCxn As String
  13.  
  14.     Dim StrSQL As String
  15.     Dim StrSQLMeasClass As String
  16.     Dim StrSQLMeas As String
  17.     Dim StrSQLOPPE As String
  18.  
  19.     Dim AddSw As Boolean
  20.     Dim editsw As Boolean
  21.  
  22.     Dim Entries As Integer
  23.  
  24.  
  25.     Dim PrvChk As Variant
  26.  
  27.     Dim MID As Integer
  28.     Dim PID As Integer
  29.     Dim Provider_Assigned_List As String
  30.  
  31.  
  32. Public Function DW_Connect()
  33.  
  34.  
  35.  
  36.     strCxn = "Provider='SQLOLEDB';Data Source=vhaomadmg;Database=NWIPerfMon;Integrated Security=SSPI;"
  37.  
  38.     Set DWConn = New ADODB.Connection
  39.  
  40.     DWConn.Open strCxn
  41.  
  42.  
  43. End Function
  44. Function Fill_Assigned_Provider_List(fld As Control, ID As Variant, row As Variant, col As Variant, code As Variant) As Variant
  45.     Static Provider_Assigned_List() As Variant
  46.     Static ProvCount As Integer
  47.  
  48.  
  49.     Const TWIPS = 1440
  50.  
  51.     Select Case code
  52.  
  53.         Case acLBInitialize                ' Initialize.
  54.             DW_Connect
  55.  
  56.             rs_Provider.CursorLocation = adUseServer
  57.  
  58.             If Not IsNull(Me.cmb_Svc_Section) Then
  59.                 StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection like '" & Me.cmb_Svc_Section.Column(0) & "';"
  60.             Else
  61.                 StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection is not null;"
  62.             End If
  63.             rs_Provider.Open StrSQL, DWConn, adOpenKeyset, adLockOptimistic, adCmdText
  64.             ReDim Preserve Provider_Assigned_List(rs_Provider.RecordCount, 1) As Variant
  65.  
  66.             Fill_Assigned_Provider_List = True
  67.             rs_Provider.MoveLast
  68.             rs_Provider.MoveFirst
  69.  
  70.             ProvCount = 0
  71.  
  72.             For chkitm = 0 To rs_Provider.RecordCount - 1
  73.                 Provider_Assigned_List(ProvCount, 0) = rs_Provider.Fields("ProviderSID")
  74.                 Provider_Assigned_List(ProvCount, 1) = rs_Provider.Fields("StaffName")
  75.                 ProvCount = ProvCount + 1
  76.                 rs_Provider.MoveNext
  77.             Next chkitm
  78.  
  79.  
  80.         Case acLBOpen                        ' Open.
  81.             Fill_Assigned_Provider_List = Timer
  82.  
  83.         Case acLBGetFormat
  84.             Fill_Assigned_Provider_List = -1
  85.  
  86.         Case acLBGetRowCount            ' Get number of rows.
  87.             Fill_Assigned_Provider_List = ProvCount
  88.  
  89.         Case acLBGetColumnCount    ' Get number of columns.
  90.             Fill_Assigned_Provider_List = 2
  91.  
  92.         Case acLBGetColumnWidth    ' Column width.
  93.             Select Case col
  94.                 Case 0:
  95.                     Fill_Assigned_Provider_List = 0
  96.                 Case 1:
  97.                     Fill_Assigned_Provider_List = 3 * TWIPS
  98.             End Select
  99.  
  100.  
  101.         Case acLBGetValue                    ' Get data.
  102.  
  103.                 Fill_Assigned_Provider_List = Provider_Assigned_List(row, col)
  104.  
  105.         Case acLBEnd
  106.             DWConn.Close
  107.             rs_Provider.Close
  108.             Erase Provider_Assigned_List
  109.  
  110.     End Select
  111. End Function
  112.  
  113. Private Sub cmb_Svc_Section_AfterUpdate()
  114.     Me.cmb_Provider.Requery
  115.  
  116. End Sub
  117.  
  118.  
Feb 3 '11 #1
6 2818
ADezii
8,834 Recognized Expert Expert
Haven't you cleared the contents of the Array as indicated in Code Line #4?
Expand|Select|Wrap|Line Numbers
  1. Case acLBEnd 
  2.   DWConn.Close 
  3.   rs_Provider.Close 
  4.   Erase Provider_Assigned_List 
As an afterthought, it may be some form of Initialization problem, try:
Expand|Select|Wrap|Line Numbers
  1. Application.Echo False
  2.  
  3. With Me![cmb_Provider]
  4.   .RowSourceType = "Fill_Assigned_Provider_List"
  5.   .RowSource = ""
  6. End With
  7.  
  8. Application.Echo True
Feb 3 '11 #2
George Allen
13 New Member
Well, that got halfway there. Now I am able to change box B and see new data in box A, but then if I change box B again, I end up with nothing in box A. I used your RowSourceType suggestion.

When I go through the second time the code jumps out when it hits the Redim statement at line #64. Is this a problem with Redim twice?
Feb 3 '11 #3
George Allen
13 New Member
Well, I fixed my own issue, but I think it was because there is something wrong with the code still, I just found a workaround. What I did was to stop building a new criteria string when I come in like I was:
Expand|Select|Wrap|Line Numbers
  1.             If Not IsNull(Me.cmb_Svc_Section) Then 
  2.                 StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection like '" & Me.cmb_Svc_Section.Column(0) & "';" 
  3.             Else 
  4.                 StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection is not null;" 
  5.             End If 
  6.  
And substituted that with a new set IF statement in the build of the array to capture the records I wanted based on the criteria filter in box A:
Expand|Select|Wrap|Line Numbers
  1.             For chkitm = 0 To rs_Provider.RecordCount - 1
  2.                 If (Not IsNull(Me.cmb_Svc_Section) And rs_Provider.Fields("ServiceSection") = Me.cmb_Svc_Section) Or (IsNull(Me.cmb_Svc_Section)) Then
  3.                     Provider_Assigned_List(ProvCount, 0) = rs_Provider.Fields("ProviderSID")
  4.                     Provider_Assigned_List(ProvCount, 1) = rs_Provider.Fields("StaffName")
  5.                     ProvCount = ProvCount + 1
  6.                 End If
  7.                 rs_Provider.MoveNext
  8.             Next chkitm
  9.  
  10.  
I wish I knew why the other version did not work, but I don't.
Feb 3 '11 #4
ADezii
8,834 Recognized Expert Expert
I've reduced your Code to a simpler State while maintaining similar functionality. This was done in an effort to eliminate some basic possibilities as to why the Code is not working. I am able to Requery the List Box as many times as I like without any adverse effects. I've attached my Demo for you to view, hopefully giving you some insight into the problem. Download the Attachment if you are interested.
What I did was to stop building a new criteria string when I come in like I was:
But this would not account for
Expand|Select|Wrap|Line Numbers
  1. Case acLBGetValue                    ' Get data.
not being evaluated, would it?
Attached Files
File Type: zip Callback Demo.zip (23.2 KB, 123 views)
Feb 3 '11 #5
George Allen
13 New Member
Thanks for the help
Feb 4 '11 #6
ADezii
8,834 Recognized Expert Expert
You are quite welcome.
Feb 4 '11 #7

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

Similar topics

0
2711
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24 to obtain SHIP_wrap.cpp and SHIP.py; the latter contains the line "import _SHIP". I compile SHIP_wrap.cpp and a bunch of files into a DLL which I have the
3
6324
by: ThinkRS232 | last post by:
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up? Following is the specific. Win32 DLL Declaration for function in MyDLL.dll extern "C" int WINAPI SpecialTimerFunction(int Val, int (*Callback)(int InVal)) C# Declaration public class MyClass
1
5176
by: Grant Hammond | last post by:
I have a callback function that populates a listbox with a list of file names in a folder. This code came from Terry Kreft/Dev Ashish some years ago. I now want to add another column to the list box to display the date of the file. I have started modifing the code to handle a 2 coulmn array, but it dosnt look like I can just change the variable to an array. Here is the code with my hichlights where I started changing it to an
8
572
by: kurtcobain1978 | last post by:
-------------------------------------------------------------------------------- I need to do the exactly same thing in VB.NET. Load a unmanaged C DLL dynamically and then call a function in which I pass the callback function as an argument. My C function being called callback as type _cdecl. Does anybody have any ideas?
7
3592
by: Kirk McDonald | last post by:
Let's say I have a function that takes a callback function as a parameter, and uses it to describe an iteration: def func(callback): for i in : callback(i) For the sake of argument, assume the iteration is something more interesting than this which relies on the callback mechanism. The function is an existing interface, and I cannot change it.
11
1979
by: The Frog | last post by:
Hi all, Maybe I am just missing something simple here, but I seem to have an issue with a callback function in A97 that is used to fill a Listbox with values. The first time the callback function is used (when the form opens) all runs well and everyone is happy. Then comes the problem - values are added to the recordset (ADO) that the callback function uses to populate the listbox. After the new values are added to the recordset, the...
6
7668
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in a .NET application and thus am looking into writing a managed C++ wrapper for in vs2005. Furthermore, this library has many callback hooks which need to be implemented by the C++ wrapper. These callback functions are declared as "extern C...
40
2337
by: Angus | last post by:
Hello I am writing a library which will write data to a user defined callback function. The function the user of my library will supply is: int (*callbackfunction)(const char*); In my libary do I create a function where user passes this callback function? How would I define the function?
6
2158
by: jmDesktop | last post by:
In a function that takes another function (function pointer) as a argument, or the callback function, which is the one that "calls back"? I'm having a hard time understanding the language. Am I right that if function A is: function A(*function pointer to B aka callback func, other arguments) { call (B); //calls }
5
6238
by: hbaf208 | last post by:
I have a combobox on a subform that is based on an SQL that uses a listbox on the unbound parent form as the criteria. When the form is first loaded, it works perfectly, limiting the dropdowns to only those associated with the listbox. However, when I update the listbox, I cannot get the combobox to requery. I've tried requery AfterUpdate on the listbox control, AfterUpdate on several subform controls, as well as trying to requery the...
0
8390
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,...
0
8909
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, 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...
0
8819
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 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...
0
7428
agi2029
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...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4221
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...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.