Hi. I can't work out how to stop the user entering data into a subform, if the parent record has not been started.
The situation...
In my database, a COURSE has one or more SESSIONS, these are separate linked tables, with each SESSION record having an associated COURSE ID number, and referential integrity enforced.
I have a COURSE form, with a SESSIONS subform within it.
I have the navigation buttons in the COURSE form enabled, so the user can move through all COURSE records, and also start a new COURSE record. As the user moves through each COURSE record, the name and date of each associated SESSION record are displayed in the SESSION subform. The subform is enabled for editting and also for creating new SESSION records.
Clearly, if the user has used the COURSE form navigation buttons to start a new COURSE record, but has not yet entered anything into the COURSE form, there is no COURSE ID number generated.
If the user then tries to enter new SESSION details into the SESSION subform, referential integrity constraints will not permit this, and an error message is generated.
What I want to do...
Best option - have the subform disabled until an associated COURSE ID number is generated. I have tried various events, and understand how to disable a control, but can't seem to find the right event triggered when using form navigation buttons to start a new record.
Second best option - hide the error message and display my own, which is less cryptic for the user. (I can display my own, but can't seem to suppress the system message, even with "setwarnings (false)" in my VB on_error event.
What I DON'T want to do - is have to disable adding records from the COURSE form, and instead create a separate ADD COURSE form.
Many thanks in advance.
Mat Mackenzie.
The situation...
In my database, a COURSE has one or more SESSIONS, these are separate linked tables, with each SESSION record having an associated COURSE ID number, and referential integrity enforced.
I have a COURSE form, with a SESSIONS subform within it.
I have the navigation buttons in the COURSE form enabled, so the user can move through all COURSE records, and also start a new COURSE record. As the user moves through each COURSE record, the name and date of each associated SESSION record are displayed in the SESSION subform. The subform is enabled for editting and also for creating new SESSION records.
Clearly, if the user has used the COURSE form navigation buttons to start a new COURSE record, but has not yet entered anything into the COURSE form, there is no COURSE ID number generated.
If the user then tries to enter new SESSION details into the SESSION subform, referential integrity constraints will not permit this, and an error message is generated.
What I want to do...
Best option - have the subform disabled until an associated COURSE ID number is generated. I have tried various events, and understand how to disable a control, but can't seem to find the right event triggered when using form navigation buttons to start a new record.
Second best option - hide the error message and display my own, which is less cryptic for the user. (I can display my own, but can't seem to suppress the system message, even with "setwarnings (false)" in my VB on_error event.
What I DON'T want to do - is have to disable adding records from the COURSE form, and instead create a separate ADD COURSE form.
Many thanks in advance.
Mat Mackenzie.