Problem with sub-sub-form

D

Dudley

I have table Company, sub table Share Class, and sub sub table Subscriber.
They are all linked by autonumber and the Share Class and Subscriber tables
are linked by field 'Class'. A command button from the main form opens a form
with linked sub form and sub sub form.

However, users who want to add a new subscriber sometimes click 'Add Share
Class record' in error instead of 'Add Subscriber record'. Entering
subscriber details (but not new share class details) then creates a new sub
sub record record which is linked by the auto number but is an orphan in
relation to the share class. To avoid this, I would like to make clicking Add
Share Class give a Yes?No box which asks 'Do you want to create a new share
class?', and exits if the user clicks No. Or is there a better way of
avoiding the problem?

Can anyone advise?

Thanks for any help.
Dudley
 
J

Jeanette Cunningham

Use some code in the before insert event of the subscriber subform to check
if the share class subform is on a new record.
Here's some sample code to use in the before insert event.

Dim strMsg As String
Dim frmParent As Form

Set frmParent = Me.Parent
If frmParent.NewRecord = True Then
Cancel = True
strMsg = "Enter a share class first"
MsgBox strMsg, vbExclamation, "Cancelled..."

End If
Set frmParent = Nothing


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Dudley

Perfect. Many thanks for your help.
Dudley

Jeanette Cunningham said:
Use some code in the before insert event of the subscriber subform to check
if the share class subform is on a new record.
Here's some sample code to use in the before insert event.

Dim strMsg As String
Dim frmParent As Form

Set frmParent = Me.Parent
If frmParent.NewRecord = True Then
Cancel = True
strMsg = "Enter a share class first"
MsgBox strMsg, vbExclamation, "Cancelled..."

End If
Set frmParent = Nothing


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia




.
 

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