Solved

Clearing information from a form

Posted on 2014-02-18
8
260 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 119

Expert Comment

by:Rey Obrero
Comment Utility
<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
Comment Utility
Now when I click on the button it clears everything but the list box.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
is that all you can post?
0
 

Author Comment

by:Megin
Comment Utility
Here is the whole database. The form I am programing is frmAssignStaff.
For-Use-on-Utter-Access.accdb
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
0
 

Author Comment

by:Megin
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:Megin
Comment Utility
I appears to be working perfectly now. Thank you!!!!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now