C
Casa
Hello;
I have a form with several command buttons. When clicked, these buttons
call up various subforms. All forms are related by one field in my main
table (represented on the main form), "Hole_ID". All other tables (i.e.
subforms) have a "Hole_ID" field on them. What I want to do is auto-fill the
"Hole_ID" field on all new records entered in on these subforms. I'm under
the impression that the way to do this is to define an event procedure in the
subforms' command buttons. This is what I have written for one of the
subforms:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "subfrm_DDH_Structure"
stLinkCriteria = "[Hole_ID]=" & "'" & Me![Hole] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
I'm a newbie when it comes to this vb stuff, so I'm not sure what I'm
missing here. Basically when I run the main form and click on a button for a
subform, it pops up alright but the new record has a blank field where the
Hole_ID should be. What should I do?
Thanks,
Casa
I have a form with several command buttons. When clicked, these buttons
call up various subforms. All forms are related by one field in my main
table (represented on the main form), "Hole_ID". All other tables (i.e.
subforms) have a "Hole_ID" field on them. What I want to do is auto-fill the
"Hole_ID" field on all new records entered in on these subforms. I'm under
the impression that the way to do this is to define an event procedure in the
subforms' command buttons. This is what I have written for one of the
subforms:
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "subfrm_DDH_Structure"
stLinkCriteria = "[Hole_ID]=" & "'" & Me![Hole] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
I'm a newbie when it comes to this vb stuff, so I'm not sure what I'm
missing here. Basically when I run the main form and click on a button for a
subform, it pops up alright but the new record has a blank field where the
Hole_ID should be. What should I do?
Thanks,
Casa