Solved

Clearing information from a form

Posted on 2014-02-18
8
262 Views
Last Modified: 2014-02-25
I have a piece of code that I am using to clear information out of three combo boxes and a list box when I click a button. The problem I am running into is that, after I click on the button, the list box clears but won't repopulate when I refresh the screen.

I suspect it might have to do with my not using Null in the formula, but when I do use Null I get errors.

Here is the code:

Private Sub btnAssign_Click()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox
If ctl.ControlSource = "" Then
   ctl = ""
End If

Case acListBox

ctl.RowSource = ""

Case Else
End Select
Next ctl

End Sub

Open in new window


Any and all help is appretiated!
0
Comment
Question by:Megin
  • 4
  • 4
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39869085
<the list box clears but won't repopulate when I refresh the screen. >

the reason is,
you removed the Rowsource of the listbox on this line


ctl.RowSource = ""


if you want to clear the listbox, just use

ctl=""

if that does not work, post back with the properties of the listbox, multi select ? rowSource , bound column ?
0
 

Author Comment

by:Megin
ID: 39869091
Now when I click on the button it clears everything but the list box.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39869095
is that all you can post?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:Megin
ID: 39869099
Here is the whole database. The form I am programing is frmAssignStaff.
For-Use-on-Utter-Access.accdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39869119
0
 

Author Comment

by:Megin
ID: 39887606
This for is still not working correctly.

One  the first entry it works fine. Then I click on Assign New Staff Member. At that point everything clears except the list of names. I want the entire list to be clear.
Then, when I try to pick a new task order, I get this warning:

"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numberic expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables"

Also, Ray, I am sorry I didn't get back to you sooner. When I saw the uploaded database I assumed it was the one I had uploaded and not a response.  Thank you for your assistance!
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39887656
0
 

Author Closing Comment

by:Megin
ID: 39887699
I appears to be working perfectly now. Thank you!!!!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question