Clearing information from a form

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!
MeginAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
0
 
Rey Obrero (Capricorn1)Commented:
<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
 
MeginAuthor Commented:
Now when I click on the button it clears everything but the list box.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Rey Obrero (Capricorn1)Commented:
is that all you can post?
0
 
MeginAuthor Commented:
Here is the whole database. The form I am programing is frmAssignStaff.
For-Use-on-Utter-Access.accdb
0
 
Rey Obrero (Capricorn1)Commented:
0
 
MeginAuthor Commented:
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
 
MeginAuthor Commented:
I appears to be working perfectly now. Thank you!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.