473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Updating a list box

I have a form (Form A) with a list box. Underneath the list box is a
command button that minimizes Form A and opens up Form B. When the
user is done with Form B, its exit button selects the minimized Form A
and closes Form B.

The list box on Form A is to display the records that are either
present or were added via Form B. However, I can't get Form A to
update the list box with the new records via VBA after I close Form B.
If I manually reload Form A, the list box is populated correctly. What
is the best way to update the list box?

Here is the code I am using to set the list box when Form A loads. I
have tried calling this on Form A's focus event, requery, after
update, etc. Thanks in advance for the help.

On Error GoTo e
Dim strSQL As String

'Set the form's filter.
Me.Form.RecordSource = strFilter

'Build the SQL string for the Failures list box.
strSQL = "SELECT [txtRMANumber], [chrFailureCategory],
[memFailureDescription] " & _
"FROM tblParetoFailures " & _
"WHERE [txtRMANumber]= """ & Me![RMA #] & """"

'Determine if this RMA has corresponding failures in the Pareto
table _
'and set the list box's row source as necessary.
If strSQL = "" Then
Me.lstFailures.RowSource = ""
Else
Me.lstFailures.RowSource = strSQL
End If
strSQL = ""

Exit Sub
e: MsgBox Err.Description
Oct 2 '08 #1
1 2027
tr******@comcast.net wrote:
I have a form (Form A) with a list box. Underneath the list box is a
command button that minimizes Form A and opens up Form B. When the
user is done with Form B, its exit button selects the minimized Form A
and closes Form B.

The list box on Form A is to display the records that are either
present or were added via Form B. However, I can't get Form A to
update the list box with the new records via VBA after I close Form B.
If I manually reload Form A, the list box is populated correctly. What
is the best way to update the list box?

Here is the code I am using to set the list box when Form A loads. I
have tried calling this on Form A's focus event, requery, after
update, etc. Thanks in advance for the help.

On Error GoTo e
Dim strSQL As String

'Set the form's filter.
Me.Form.RecordSource = strFilter

'Build the SQL string for the Failures list box.
strSQL = "SELECT [txtRMANumber], [chrFailureCategory],
[memFailureDescription] " & _
"FROM tblParetoFailures " & _
"WHERE [txtRMANumber]= """ & Me![RMA #] & """"

'Determine if this RMA has corresponding failures in the Pareto
table _
'and set the list box's row source as necessary.
If strSQL = "" Then
Me.lstFailures.RowSource = ""
Else
Me.lstFailures.RowSource = strSQL
End If
strSQL = ""

Exit Sub
e: MsgBox Err.Description
Prior to exiting FormB you could requery the listbox in FormA if FormA
is still open. Or in the OnActivate event of FormA do a requery of the
listbox. You could set a flag in FormA when you call FormB so that in
the OnActivate in FormA only requeries the listbox if you called/opened
FormB.

Stop
http://www.youtube.com/watch?v=JFYzU5U-Ytc

Oct 2 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
3
by: Robin Tucker | last post by:
Hi, I'm in the process of implementing a multi-user system containing an adjacency list (tree structure). I'm using a TIMESTAMP field on each record in the adjacency list in order to tell when...
9
by: simon.harris | last post by:
I have a 'master' stock list with current stock levels (integer) and another table that contains transactions (i.e. item#, #items added/ removed, date, user etc). What I need is an update query...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
2
by: mark4asp | last post by:
Q: Initialising and updating a class with only static members & database dependency I have a class with the following members: public static List<ACISACIS_List; static AssetClass() { //...
2
by: Spam Catcher | last post by:
Hi All, I want to bind a datagridview or ListView to a List that is constantly being updated (items are added/removed all the time). Any ideas what the best way is to do this? I tried binding...
0
by: adalyc | last post by:
I NEED SOME GUIDENCE WITH UPDATING A COLLECTION OF ITEMS IN A LIST BOX WHEN THE USER CLICKS ON A BUTTON FROM ANOTHER FORM,, i HAVE LISTED THE PROBLEM PARTIALLY. I fIGURED OUT MOST OF THE PROBLEM...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
1
by: Edwin.Madari | last post by:
by the way, iterating over bar will throw KeyError if that key does not exist in foo. to see that in action, simply set another key in bar after copy.deepcopy stmt in this example.. bar = 0 and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
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
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...
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
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...
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...

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.