Attn: Ken Snell - Parent Child Link Problem

  • Thread starter Thread starter Bob B.
  • Start date Start date
B

Bob B.

Hi Ken!

I created a form with a subform inside with "ID" field as a link.... all
went fine untill i added my own buttons ... add.. edit and delete and
save....

The child subform became color gray and and can't input anything... it seems
that the link between the form and subform doesn't work... already checked
the propertis and both are still linked supposed to be by the "ID" field.

I deleted the buttons I made but the same problem still exist....
 
Ken Snell said:
Do you still see records on the subform even though its "greyed out"? Or is
the subform "empty"?
Hi Ken!

No I don't see anything just the header of the subform..
Is the "Allow Additions" property set to Yes for the subform's source
object? Same for "Allow Edits" and "Allow Deletions"?
Allow adittions set to yes Allow edits No since I have a button that would
set the property to yes.... Allow deletions yes
Something that your buttons added/did has affected the setup somehow, it
seems. How did you code for those buttons: write your own? or use wizard?

I wrote my own code... used docmd.runcommand...

It worked after I deleted the subform and reinserted it 5 times.... it
didn't work 4 times.... Is it a bug???

Thanks for friendly response...
 
Really difficult to say without knowing more details about the code, how you
set up the buttons, etc. Perhaps the form has become corrupted while you
were adding the new buttons. Does your code by any chance change the
recordsource of the subform?

Other than this, I can't offer much more specific advice. The RunCommand
action can be tricky...you must be sure that you've set focus properly to
the subform before you run it, else it'll act on the main form if that is
where the buttons are located that run the commands.
 
Hi Ken... this are the codes of the buttons.... By the way since i want to
use one record manipulation menu for both the subform and the main form....
how do i make the command work on which ever is focused......

Thanks.

I agree with you I think the runcommand somehow corrupted the form...

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click


DoCmd.RunCommand acCmdRecordsGoToNew

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub
Private Sub Command20_Click()
DoCmd.SetWarnings False
If MsgBox("Confirm deletion of the record?", _
vbQuestion + vbYesNo + vbDefaultButton2, _
"Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If
Exit_cmdDelete_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click


Exit_Command20_Click:
Exit Sub

Err_Command20_Click:
MsgBox Err.Description
Resume Exit_Command20_Click

End Sub



Private Sub Command21_Click()
DoCmd.RunCommand acCmdSelectRecord
Me.AllowEdits = True
MsgBox "The form is now in edit mode"
End Sub

Private Sub Command22_Click()
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Record Saved"
Me.AllowEdits = False
MsgBox "Edit Now Uneditable"



End Sub

Private Sub Form_AfterUpdate()
Me.AllowEdits = False
End Sub
 
When you use the RunCommand actions, you must first set the focus to the
part of the form on which it's to act. If you want to have it act on a
subform record, and the code is in the main form, precede your RunCommand
action with a SetFocus action that puts the focus on the subform:
Me.SubformName.SetFocus

I'm guessing that your code is running on the main form's record and not on
the subform's record.
 
A macro can use the SetValue to set the AllowEdits property of the form:

Action: SetValue
Control: Forms!FormName.AllowEdits
Expression: True
 
Back
Top