Enable=False if key field is Null

  • Thread starter Tom via AccessMonster.com
  • Start date
T

Tom via AccessMonster.com

Hi,
I put some code in my subforms on current event to check if the foriegn key
field contains a null value. If it does I dont want the user to be able to
enter anything into the forms fields. Because to do that you would of course
want a record in the parent. The parent table is Agen. The linked field is
AgenID. The other table (the one that makes up the subform) is AgenContact.
This is the code;

Private Sub Form_Current()
If IsNull(Me.[AgenID]) Then
Me.AgenContactFirstName.Enabled = False
Me.AgenContactFirstName.Locked = False
End If
End Sub

In order to disable all the controls on the form would I have to list them
all in the code and set Enabled to false? Another control on the form would
be AgenContactLastName. Is there some code I could put into the AgenID field
to check if it has changed (ie. someone clicked the record selector and moved
to a record that has a entry in AgenID)?

Thanks,
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top