Help on Enabling or Disabling fields????

tafnuef1

Registered User.
Local time
Today, 15:31
Joined
Apr 22, 2010
Messages
43
So close to finishing my database..

Question, can my fields be greyed out till each previous one is filled in? What is the procedure to do so. I have found so many ways in some of the forum but no true procdure yet.

Ok here is my fields
Field one is called Batch_Number_ID (user will enter a batch number)
Field two is called Document_Count (user will enter number of documents)
Field three is Date_of_Audit (user will enter a masked date)
Field four is a combo box called Document_Type (user will choose a document type)
Field five is a Combo box called Prepper_Name (user will choose a name)
Field six is a Combo bos called Indexer_Name (user will choose a name)

Field Seven is inside a subform of the mainform and is also a combo box called Prepper_Error (user will choose an error code)

Field Eight is inside a subform of the mainform and is also a combo box called Indexer_Error (user will choose an error code)

So how do I keep all of these locked or disabled till the previous one is entered???
 
To "grey" out a filed set it's Enabled Property to False.

In the form's On Current event you would need to preform a logical (If Then) test on each of your control to determine if you want their Enabled properties set to True or False. Then in the On Lost Focus event of each control you would need some code something like;
Code:
If Me.ControlName [COLOR="SeaGreen"]'Test for lack of data[/COLOR]
     MsgBox "Please enter data in field name"
     Cancel = True
     Exit Sub
Else
     Me.NextControlName.Enabled = True
     Me.NextControlName.SetFocus
End If
 
I was playing around with the Exit event and it works pretty good. I check to see if the value of the field is not empty before enabling the the next field. Subreports are a bit of a pain, but still workable.
 
Thank you John..

forgive me with more questions, I have learned so much creating this database and using this forum.. however here is my question..

In regards to your post: "On Current event you would need to preform a logical (If Then) test on each of your control to determine if you want their Enabled properties set to True or False."

How would I set that up?
 
THANK YOU JOHN this finally worked for me:

For my text Boxes I used the below code under Lost Focus event. BUT on combo boxes I used this under the Change event. Worked great!!!

If Me.Document_Type = "" Then
MsgBox "Please enter a Document Type"
Cancel = True

Exit Sub
Else
Me.Prepper_Name.Enabled = True
Me.Prepper_Name.SetFocus


End If

NOW last question my last two combo boxes are in a subform. Where and how do I set up my event from my last combo box in the mainform to enable my first combo box in my subform?

Here are my controls
Last combo box in mainform: Indexer_Name
Subform name: Audit_Errors_Subform
First combo box Control in Subform: Prepper_Error

(NOTE.. I would love it if I could check a control box on the mainform to see if a certain choice is made. Otherwise they would not need to put in a Prepper error.. )
 
When I was experimenting, I 'disabled' the subform. Thus when I got to the last combo box on the the main form, I enabled the subform and thus enabling the combo box. I tried disabling the combo box from the main form, but it keep telling me that the combo box had the focus and would not let me disable it. I did not trying enabling the combo box in the subreport.

FYI: To access the subreports fields Audit_Error_Subform.Controls(0) ' for first field
 
....

NOW last question my last two combo boxes are in a subform. Where and how do I set up my event from my last combo box in the mainform to enable my first combo box in my subform?

...

Bookmark this link it gives you the correct syntax for referring to subforms and their controls.
 

Users who are viewing this thread

Back
Top Bottom