473,382 Members | 1,710 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,382 software developers and data experts.

Refreshing a two column list box after updating records in the source table

Apologies in advance. I've seen similar questions, but none of the solutions seem to be working for me...

I have a form that allows a user to select mutiple items (payroll deduction codes) in a list box. The values are drawn from a table called PayrollCodes. In the second list box, the user chooses a category that the items from the first list belong to. I have a command button with code attached to the OnClick Event that then records the category selected to the records that match the payroll deduction codes selected. I have a third list box (CodeAndCategory) that shows the values in the table PayrollCodes. There are two columns in this list box- one for the payroll code and one for the category. I would like this CodeAndCategory list box to show the updated information after the command button is pressed and the table updated. As I have it now, I have the following code right before the function ends:

Expand|Select|Wrap|Line Numbers
  1. Me.CodeAndCategory.Requery
  2. Me.Repaint
If I scroll the listbox down and back up, the record in CodeAndCategory refreshes. If I manually close and open the form, CodeAndCategory refreshes.
I have tried using code to close and reopen the form, but that did not work.
Will be happy to include all code if need be.
Sep 21 '07 #1
4 1965
barry07
47
I'm guessing, but try Refresh or Requery - Repaint only reformats the screen it does nothing with data.
You may have to Requery/Refresh each combo box.
If that doesn't work can you post the RowSource for each combo box?
Sep 21 '07 #2
Thanks so much for your quick response. I have modified the code as follows:

Expand|Select|Wrap|Line Numbers
  1. Me.CodeList.Requery
  2. Me.CatList.Requery
  3. Me.CodeAndCategory.Requery
  4. Me.Refresh
and still the same issue. Here are the Rowsource contents:

For listbox CodeList:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblUniqueCodes.Code FROM tblUniqueCodes; 
For listbox CatList:
tblProdCats

For listbox CodeAndCategory:
tblUniqueCodes

Thanks again for your help!!
Sep 21 '07 #3
Denburt
1,356 Expert 1GB
I don't see any issues with what you posted but I also don't see the subsequent combo boxes criteria however since your last post I can skip to the point since it sounds like the code requery or what have you is running before the process of updating your table has finished. The solution for that would be to use either "DBEngine.Idle" or try "DoEvents" to see if that helps. Let us know how things go.
Sep 27 '07 #4
Thank you for the response. I had almost given up on hearing anything, so I apologize for just now trying your suggestion.

No luck... Here is the new code. I'm not familiar with DBEngine.Idle, so I hope I used it correctly.

Expand|Select|Wrap|Line Numbers
  1. CodeListItems = [CodeList].ListCount - 1
  2. For CodeListCounter = 0 To CodeListItems
  3.     If [CodeList].Selected(CodeListCounter) = True Then
  4.     rst.Open "SELECT * FROM tblUniqueCodes WHERE (tblUniqueCodes.Code) = '" & Me![CodeList].Column(0, CodeListCounter) & "'", CurConn, , , adCmdText
  5.     rst![ProdCat] = Me![CatList]
  6.     rst.Update
  7.     rst.Close
  8.     End If
  9. Next CodeListCounter
  10.  
  11. DBEngine.Idle
  12.  
  13. Me.CodeAndCategory.Requery
  14.  
  15. MsgBox "The codes have been associated with the " & Forms![Multi List Test]![CatList] & " category."
  16.  
  17. Exit_Command8_Click:
  18.     Exit Sub
  19.  
  20. Err_Command8_Click:
  21.     MsgBox Err.Description
  22.     Resume Exit_Command8_Click
  23.  
  24. End Sub
The interesting thing is you'll notice I have a confirmation message box pop up for the user. If you click, hold down the mouse button for a second, and release, this works great and the List Box is updated. If you click and release too quickly, no update to the table.
Oct 5 '07 #5

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

Similar topics

3
by: Bernard André | last post by:
Hi All, context: I am using Access 97 tablkes with VB. I can see records in the MDB, using Adodc and datagrid. No problem. But when doing: rsprivate.AddNew rsprivate!For =...
5
by: Scott Tilton | last post by:
I am having a terrible time getting this to work. I am hoping someone out there can help me with very specific code examples. I am trying to get the linked tables in my Access 97 database to be...
20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
0
by: | last post by:
I am updating MS access tables with data in an xml document. I create two dataset, one for existing data and one for new data. I fill the first dataset with the records from MS Access, the second...
1
by: Vinny Vinn | last post by:
I would like to insert a new column in DataTable at a specified position at runtime. Unfortunatly, the DataColumnCollection does not expose any method to do this (like AddAt),Any ideas would be...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
5
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x...
5
by: handoyo | last post by:
Hi all,i'm trying to show updated data in existing html td.. For example i got column that show last modified datetime,then i want to update data again,the column will changed to current time without...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.