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. -
Option Compare Database
-
Option Explicit
-
Dim chkitm As Variant
-
Dim ProvID As Integer
-
Dim rs_Provider As New ADODB.Recordset
-
Dim rs_Measure_Class As New ADODB.Recordset
-
Dim rs_Measure As New ADODB.Recordset
-
Dim rs_OPPE As New ADODB.Recordset
-
Dim FilterCrit As String
-
-
Dim DWConn As New ADODB.Connection
-
Dim strCxn As String
-
-
Dim StrSQL As String
-
Dim StrSQLMeasClass As String
-
Dim StrSQLMeas As String
-
Dim StrSQLOPPE As String
-
-
Dim AddSw As Boolean
-
Dim editsw As Boolean
-
-
Dim Entries As Integer
-
-
-
Dim PrvChk As Variant
-
-
Dim MID As Integer
-
Dim PID As Integer
-
Dim Provider_Assigned_List As String
-
-
-
Public Function DW_Connect()
-
-
-
-
strCxn = "Provider='SQLOLEDB';Data Source=vhaomadmg;Database=NWIPerfMon;Integrated Security=SSPI;"
-
-
Set DWConn = New ADODB.Connection
-
-
DWConn.Open strCxn
-
-
-
End Function
-
Function Fill_Assigned_Provider_List(fld As Control, ID As Variant, row As Variant, col As Variant, code As Variant) As Variant
-
Static Provider_Assigned_List() As Variant
-
Static ProvCount As Integer
-
-
-
Const TWIPS = 1440
-
-
Select Case code
-
-
Case acLBInitialize ' Initialize.
-
DW_Connect
-
-
rs_Provider.CursorLocation = adUseServer
-
-
If Not IsNull(Me.cmb_Svc_Section) Then
-
StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection like '" & Me.cmb_Svc_Section.Column(0) & "';"
-
Else
-
StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection is not null;"
-
End If
-
rs_Provider.Open StrSQL, DWConn, adOpenKeyset, adLockOptimistic, adCmdText
-
ReDim Preserve Provider_Assigned_List(rs_Provider.RecordCount, 1) As Variant
-
-
Fill_Assigned_Provider_List = True
-
rs_Provider.MoveLast
-
rs_Provider.MoveFirst
-
-
ProvCount = 0
-
-
For chkitm = 0 To rs_Provider.RecordCount - 1
-
Provider_Assigned_List(ProvCount, 0) = rs_Provider.Fields("ProviderSID")
-
Provider_Assigned_List(ProvCount, 1) = rs_Provider.Fields("StaffName")
-
ProvCount = ProvCount + 1
-
rs_Provider.MoveNext
-
Next chkitm
-
-
-
Case acLBOpen ' Open.
-
Fill_Assigned_Provider_List = Timer
-
-
Case acLBGetFormat
-
Fill_Assigned_Provider_List = -1
-
-
Case acLBGetRowCount ' Get number of rows.
-
Fill_Assigned_Provider_List = ProvCount
-
-
Case acLBGetColumnCount ' Get number of columns.
-
Fill_Assigned_Provider_List = 2
-
-
Case acLBGetColumnWidth ' Column width.
-
Select Case col
-
Case 0:
-
Fill_Assigned_Provider_List = 0
-
Case 1:
-
Fill_Assigned_Provider_List = 3 * TWIPS
-
End Select
-
-
-
Case acLBGetValue ' Get data.
-
-
Fill_Assigned_Provider_List = Provider_Assigned_List(row, col)
-
-
Case acLBEnd
-
DWConn.Close
-
rs_Provider.Close
-
Erase Provider_Assigned_List
-
-
End Select
-
End Function
-
-
Private Sub cmb_Svc_Section_AfterUpdate()
-
Me.cmb_Provider.Requery
-
-
End Sub
-
-
6 2818 ADezii 8,834
Recognized Expert Expert
Haven't you cleared the contents of the Array as indicated in Code Line #4? - Case acLBEnd
-
DWConn.Close
-
rs_Provider.Close
-
Erase Provider_Assigned_List
As an afterthought, it may be some form of Initialization problem, try: - Application.Echo False
-
-
With Me![cmb_Provider]
-
.RowSourceType = "Fill_Assigned_Provider_List"
-
.RowSource = ""
-
End With
-
-
Application.Echo True
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?
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: -
If Not IsNull(Me.cmb_Svc_Section) Then
-
StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection like '" & Me.cmb_Svc_Section.Column(0) & "';"
-
Else
-
StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection is not null;"
-
End If
-
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: -
For chkitm = 0 To rs_Provider.RecordCount - 1
-
If (Not IsNull(Me.cmb_Svc_Section) And rs_Provider.Fields("ServiceSection") = Me.cmb_Svc_Section) Or (IsNull(Me.cmb_Svc_Section)) Then
-
Provider_Assigned_List(ProvCount, 0) = rs_Provider.Fields("ProviderSID")
-
Provider_Assigned_List(ProvCount, 1) = rs_Provider.Fields("StaffName")
-
ProvCount = ProvCount + 1
-
End If
-
rs_Provider.MoveNext
-
Next chkitm
-
-
I wish I knew why the other version did not work, but I don't.
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 - Case acLBGetValue ' Get data.
not being evaluated, would it?
ADezii 8,834
Recognized Expert Expert Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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
|
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
|
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?
|
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.
| |
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...
|
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...
|
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?
|
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
}
|
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...
|
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: 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: 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...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |