Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access Form 1

Status
Not open for further replies.

AccessNewbie2

Programmer
Dec 13, 2006
4
US
Hey all. New user to Tek-Tips and to MS Access. Hopefully this isn't a dumb question. I have a form with about 50 or so controls on it. Some checkboxes, Comboboxes, and textboxes. I'd like to reset all of the controls to their default value in the form load event. None of the controls are grouped. Is this possible?
 
And what would be a
1. default value for checkboxes? - checked, unchecked, greyed?
2. default value for Comboboxes? First value in it, last? None?
3. default value for textboxes? Empty? Default text? Today's Date?

All of it is possible, you just need to know what you want to do....

---- Andy
 
Sorry, I should have put that in the original post.

Checkboxes -- Unchecked
Comboboxes -- Empty
Textboxes -- Empty
 
This is VB6 code, but it should give you an idea what to do and it should work for you:
Code:
Dim cntlControl As Control

For Each cntlControl In Me.Controls
    If TypeOf cntlControl Is ComboBox Then
        cntlControl.Visible = False
    End If
    If TypeOf cntlControl Is CommandButton Then        
        cntlControl.Enabled = False
    End If
    If TypeOf cntlControl Is OptionButton Then
        cntlControl.Value = False
    End If
    If TypeOf cntlControl Is TextBox Then
        cntlControl.Text = ""
    End If
Next cntlControl

HTH

---- Andy
 
Andy, Thanks for the reply. In VBA the properties for the control object is as follows:


Application Property
Column Property
Controls Property
Form Property
Hyperlink Property
ItemData Property
ItemsSelected Property
Object Property
ObjectVerbs Property
OldValue Property
Pages Property
Parent Property
Properties Property
Report Property
Selected Property
SmartTags Property

Not quite sure which one I should use. Any ideas?

Thanks again
 
I don't know what you mean by this properties question.

Did you try my code? it will work in your VBA.

---- Andy
 
Andy,
Thanks again for your help. I did try your code and it works. I was letting MS Access help me with smart help, you know when you type the period and selections come up. Thanks again for staying with me to a good conclusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top