[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Reset Access Form after change to field

Posted on 2009-05-05
4
Medium Priority
?
574 Views
Last Modified: 2013-11-28
I have a form with all data entry fields set to disabled. The form is used to enter issues and data associated with 3 different issue types. I have a combo box that allows the user to select the issue type they are entering. I have the code below that enables and highlights required fields for the selected issue types. The code works fine with one exception - if the user mistakenly selects the wrong issue type, when they go back and select the proper type the fields that were previously enabled and highlighted remain as such.

I would like to make it so that if the user selects the wrong issue type and then changes it, all the fields are set to their original state and then the appropriate fields are enabled and highlighted based on the corrected selection.

Essentially:
Wrong selection made - fields for that selection enabled\highlighted.
Correct selection made - irrelevant fields locked\highlight removed, appropriate fields enabled\highlighted.

Or is it just easier to reload the form and make the proper selections from that point? I have a few required fields so I would like to suppress prompting in that case. I can't seem to get this method to work either.

Thanks!
Private Sub Category_AfterUpdate()
 
On Error GoTo Error_Handler
 
Me.Category.SetFocus
If Me.Category.Text = "Product Hold" Then
    Me.Description.BorderColor = RGB(0, 255, 0)
    Me.Description.Enabled = True
End If
If Me.Category.Text = "PCAR" Then
    Me.Comments.BorderColor = RGB(0, 255, 0)
    Me.Comments.Enabled = True
End If
Exit Sub
 
Error_Handler:
   MsgBox Err.Description, vbOKOnly, "Error #" & Err.Number
   Exit Sub
   
End Sub

Open in new window

0
Comment
Question by:Haze0830
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24306906
create a sub the set all the controls to enable and other properties to default

then call the sub first in the afterupdate event of the combo before setting the other controls to the desired setting
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 24306935

sub resetControls()
me.description.enabled=true
me.comments.enabled=true

etc....

end sub


Private Sub Category_AfterUpdate()
 
On Error GoTo Error_Handler
 
resetControls 'this will reset all the controls


Me.Category.SetFocus
If Me.Category.Text = "Product Hold" Then
    Me.Description.BorderColor = RGB(0, 255, 0)
    Me.Description.Enabled = True
End If
If Me.Category.Text = "PCAR" Then
    Me.Comments.BorderColor = RGB(0, 255, 0)
    Me.Comments.Enabled = True
End If
Exit Sub
 
Error_Handler:
   MsgBox Err.Description, vbOKOnly, "Error #" & Err.Number
   Exit Sub
   
End Sub
0
 
LVL 2

Author Comment

by:Haze0830
ID: 24307955
that was incredibly simple and effective. I only changed one portion - instead of enabled I set it to disabled as I want all the fields to be locked by default.

Thanks!!
0
 
LVL 2

Author Closing Comment

by:Haze0830
ID: 31578114
Thanks again!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

656 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