So, I have two comboboxes on my form. One has a vlaue list (A), then other uses a callback function to populate (B) items based on the combo A selection. If I select something in A, then the function correctly populates B. I can do this over and over. However, if I select an item in B, then go back to A to select a different filter, the callback function does not populate B. One thing I noticed was that the combobox.value is still set to the selected value, but clearing that does not help. Ideas? -
-
COMBOBOX A AFTER UPDATE
-
Private Sub cmb_Svc_Section_AfterUpdate()
-
-
Redraw_Form
-
-
Application.Echo False
-
-
With Me![cmb_Provider]
-
.RowSourceType = "Fill_Assigned_Provider_List"
-
.RowSource = ""
-
End With
-
-
Application.Echo True
-
-
-
End Sub
-
-
COMBOBOX B CALLBACK 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
-
-
-
StrSQL = "Select * from dim.Provider where InactivationDate is null and ServiceSection is not null;"
-
' rs_Provider.CursorLocation = adUseServer
-
rs_Provider.Open StrSQL, DWConn, adOpenKeyset, adLockOptimistic, adCmdText
-
-
rs_Provider.MoveLast
-
rs_Provider.MoveFirst
-
-
ReDim Preserve Provider_Assigned_List(rs_Provider.RecordCount, 1) As Variant
-
-
Fill_Assigned_Provider_List = True
-
-
-
ProvCount = 0
-
-
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
-
-
-
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
-
-
Actually, I was just looking at this Thread and thinking quite the opposite. To me it was apparent that the problem resided somewhere in the AfterUpdate() Event of B and was thinking along the lines of reopening an existing Connection which may be causing the problem, but was obviously wrong. In any event, nice job on figuring it out. P.S. - Now that you have resolved the problem, you may wish to consider replacing - With Me![cmb_Provider]
-
.RowSourceType = "Fill_Assigned_Provider_List"
-
.RowSource = ""
-
End With
with - Me![cmb_Provider].Requery
in the AfterUpdate() Event of cmb_Svc-Section. Not sure, but it may be more efficient than redefining the Callback to populate cmb_Provider.
8 1572
Try NOT Erasing the contents of the Array in Line #86, and see what happens, namely: - 'Erase Provider_Assigned_List Comment Line #86
This is how Access, requests, and receives its Data for the specific Row/Column combination as in Line #81: -
Case acLBGetValue ' Get data.
-
Fill_Assigned_Provider_List = Provider_Assigned_List(row, col)
OK, I will give this a shot. I do realize that the acLBGetValue is where the data is being placed in the control, but the code never goes there when it should be.
Nope, no better. Removing ERASE line does not affect the content of the combobox. It still ends up blank.
I followed code in the callback function. Once I select a item in box B, then select the Box A (even before I make a selection) the callback function is called by the control for the following codes in sequence (By breakpoint check on line 28):
6, 7, 6, 7, 6, 7
After this I make a selection and the callback gets thse codes in sequence:
8,9
Then the thread passes ot the box A Afterupdate subroutine. It walks through the steps until the box A requery, where it jumps back into the callback function with the code 0 then jumos out of the routine and back to the form.
So, it never attempts to refill the box B from my selection in box A once I have made a selection in box B.
Is there any Code in the AfterUpdate() Event of Combo B, and if so, what is it?
Yes there is. The code connects to another SQL table and then changes the size and layout of th eform to accomodate data from that other table. -
Private Sub cmb_Provider_AfterUpdate()
-
Redraw_Form
-
DW_Connect
-
-
rs_ScoreData.CursorLocation = adUseServer
-
-
strSQLScore = "Select oppesid, measure_ClassSID,measure_Class, Measure, Benchmark, Max(ScoreDate) as Last_Date, sum(Numerator) as Num, sum(Denominator) as Denom from dbo.vw_Score_Result where ProviderSID = " & Me.cmb_Provider.Column(0) & " and ActiveDate <= '" & Me.txt_End_Date & "' and (inactivedate is null or (inactivedate > '" & Me.txt_Start_Date & "' and inactivedate < '" & Me.txt_End_Date & "')) group by oppesid, measure_ClassSID,measure_Class, Measure, Benchmark order by measure_ClassSID, Measure;"
-
rs_ScoreData.Open strSQLScore, DWConn, adOpenKeyset, adLockOptimistic, adCmdText
-
-
-
Set TmpTblScore_Data = CurrentDb.OpenRecordset("Score", dbOpenDynaset, dbSeeChanges)
-
Do While Not TmpTblScore_Data.EOF
-
TmpTblScore_Data.Delete
-
TmpTblScore_Data.MoveNext
-
Loop
-
-
Do While Not rs_ScoreData.EOF
-
TmpTblScore_Data.AddNew
-
TmpTblScore_Data.Fields("OPPESID") = rs_ScoreData.Fields("OPPESID")
-
TmpTblScore_Data.Fields("Measure_ClassSID") = rs_ScoreData.Fields("Measure_ClassSID")
-
TmpTblScore_Data.Fields("Measure_Class") = rs_ScoreData.Fields("Measure_Class")
-
TmpTblScore_Data.Fields("Measure") = rs_ScoreData.Fields("Measure")
-
TmpTblScore_Data.Fields("Benchmark") = rs_ScoreData.Fields("Benchmark")
-
TmpTblScore_Data.Fields("Last_Date") = rs_ScoreData.Fields("Last_Date")
-
TmpTblScore_Data.Fields("Num") = rs_ScoreData.Fields("Num")
-
TmpTblScore_Data.Fields("Denom") = rs_ScoreData.Fields("Denom")
-
TmpTblScore_Data.Update
-
rs_ScoreData.MoveNext
-
Loop
-
-
-
TopPos = 0
-
-
If TmpTblScore_Data.RecordCount > 0 Then
-
Set rs_Score_Class = CurrentDb.OpenRecordset("SELECT Measure_ClassSID, Count(OPPESID) AS Num_Rec FROM Score GROUP BY Measure_ClassSID;", dbOpenDynaset, dbSeeChanges)
-
rs_Score_Class.MoveFirst
-
Do While Not rs_Score_Class.EOF
-
Select Case rs_Score_Class.Fields("Measure_ClassSID")
-
Case 1
-
Me.subfrm_First.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_First.Visible = True
-
Me.subfrm_First.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 2
-
Me.subfrm_Second.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Second.Visible = True
-
Me.subfrm_Second.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 3
-
-
Me.subfrm_Third.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Third.Visible = True
-
Me.subfrm_Third.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 4
-
-
Me.subfrm_Fourth.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Fourth.Visible = True
-
Me.subfrm_Fourth.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 5
-
-
Me.subfrm_Fifth.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Fifth.Visible = True
-
Me.subfrm_Fifth.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 6
-
-
Me.subfrm_Sixth.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Sixth.Visible = True
-
Me.subfrm_Sixth.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 7
-
-
Me.subfrm_Seventh.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Seventh.Visible = True
-
Me.subfrm_Seventh.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Case 8
-
-
Me.subfrm_Eight.Move Left:=0, Top:=TopPos, Height:=(0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips
-
Me.subfrm_Eight.Visible = True
-
Me.subfrm_Eight.Requery
-
TopPos = TopPos + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
Me.InsideHeight = Me.InsideHeight + ((0.65 + (rs_Score_Class.Fields("Num_Rec") * 0.425)) * twips)
-
End Select
-
rs_Score_Class.MoveNext
-
Loop
-
-
End If
-
-
TmpTblScore_Data.Close
-
-
rs_ScoreData.Close
-
-
-
If Me.subfrm_First.Visible = True Then Me.subfrm_First.SetFocus
-
-
DWConn.Close
-
-
-
-
End Sub
-
-
Figured it out. I was closing my ADO connection eveytime I used it so I could try and release resources I was not using. Everytime I closed the connection through a DWConn.Close, I was wiping out my provider list. My thought was that each time I called the connection for an ADO call it was a seperate connection. Guessed wrong.
Thanks for your help. Your insistence on looking at Box B afterupdate pointed me in the right direction.
Actually, I was just looking at this Thread and thinking quite the opposite. To me it was apparent that the problem resided somewhere in the AfterUpdate() Event of B and was thinking along the lines of reopening an existing Connection which may be causing the problem, but was obviously wrong. In any event, nice job on figuring it out. P.S. - Now that you have resolved the problem, you may wish to consider replacing - With Me![cmb_Provider]
-
.RowSourceType = "Fill_Assigned_Provider_List"
-
.RowSource = ""
-
End With
with - Me![cmb_Provider].Requery
in the AfterUpdate() Event of cmb_Svc-Section. Not sure, but it may be more efficient than redefining the Callback to populate cmb_Provider.
Thanks again. I will look at making the change. It was an earlier suggestion of yours to try and make another part of this work.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Edward |
last post by:
Access 2k FE/BE
My application allows users to enter employee hours against rotas
(i.e. who is rostered on, and when).
They further want a function to output a report showing the number of...
|
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...
|
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...
|
by: sajin |
last post by:
Hi All..
We are using VB .Net 2005 for implementing an API. API needs to
generate events. For this client wants us to use Windows Callback
(delegate implementation). The intention of using...
|
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...
|
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...
|
by: Pradeep |
last post by:
Hi all,
Can any one explain me what is callback function....
I have written some code after reading some tutorials from internet...
But I am not sure is it a right way to write a call back...
|
by: jack113256 |
last post by:
Hi everyone:
I have a question in using Callback function, there is my code:
/******* code start *********/
#include <stdio.h>
void a();
void b();
void run();
|
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...
|
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...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |