Form & subform relationship : required field in subform

R

Ronan

Hello,

As I am not finding any solution for now, I will try here...

I built a database to collect information about experts (name,
address, etc.).
In the main form called "FM_contact", there are subforms with other
datas such as "fields of expertise" and "occupations". These subforms
are based on a field (combobox list of id/alias related to a table)
and appears in the continuous mode.
My problem is :
I would like to check, before updating any record (new or addition),
that at least one "field of expertise" has been chosen in the subform
combobox list, as it is like "keywords" to make request later. It is a
required field.

I tried to put a procedure in the "beforeupdate" event but it has no
sense because when any subform receives the focus, access is updating
and recording the main form. So it cannot work.

Furthermore, I cannot give the focus to the subform, which is located
on a tab control, or to the control (combobox list) in the subform...
It does not work.

Does anyone have any solution ? any idea ?

Thank you very much in advance.

Ronan

Here is the code :
Before_update

If Forms("FM_contact")("domexpcont").Form.RecordsetClone.RecordCount =
0 Then
MsgBox "Veuillez entrer au moins un domaine d'expertise"
Forms("FM_contact")("domexpcont").SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl ("ctrlexp")

End If
 

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