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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Properties

Status
Not open for further replies.

mpnorris

IS-IT--Management
Dec 31, 2002
66
US
I hope someone can help me out. I have a form that enables and disables text boxes based on what is chosen from a dropdown box.

How can I change whether a field on the table is required or not based on what is chosen on the form?

I tried setting the field to required. When I chose something from the dropdown box that made the text box bound to the required field disabled, I could not commit the entry to the table.

The only way to get every scenerio to work was to keep the field not required. The problem is that the entry can be saved without data being put into the field.

Any suggestions. I do not know how to change the properties of a field in the database, based on other entries in the database.

Any help will be greatly appreciated.
 
You need to take control of the form yourself.

From what you have written, I expect you are enabling/disabling controls on the form depending on the selction made in the ComboBox.

Before you save the record, test the fields like this -

If Field1.Enabled then
(...Field validation code...)
End If

If Field2.Enabled then
(...Field validation code...)
...


 
You are correct in that I am enabling/disabling controls on the form depending on what is chosen from the comboBox. My question would the "Field Validation code" look like. I am not sure of the syntax for checking the properties of the fields in the table. Is is just like a form? HOw do you indicate that you are referencing a field in a table, not the form?

Is there a way to indicate that a control on a form is required? The only area that I have seen that you can indicate it is required is at the table level.

Any help is greatly appreciated.

Thank you.
 
I've got the same problem sort of I need to validate controls can you post your solution please. Thanks
 
What I used to get past this hurdle is on the Add Record click event I used an If statement to check if the control is enabled. If it is enabled I checked to see if the control was empty by using the IsNull() function. Here is a sample of the code:

If txtTextBox.Enabled = true then
If IsNull(txtTextBox) then
MsgBox "Please enter something in the box"
DoCmd.GoToControl "txtTextBox"
End If
End If

Hopefully this will help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top