D
Darryl
Hello NewGroup:
I have a mainform and a related subform.
On the subform the related records are listed in a tabular
format. The last record in this table is a blank record.
When the user "double-clicks" the blank record, another
edit form appears where the user can enter the data.
My problem is trying to assign a primary key to this new
record, which comes from the mainform.
I've added the primary key field as "hidden fields" to the
mainform and subform.
I've tried capturing the key field into a "global"
variable. I've tried to reference the key field with
Forms!mainform!CustomerId
mainform.CustomerId
I've even tried to set the default of the key field,
through the "properties" window but, no luck.
Here's the code:
Private Sub TelephoneNo_DblClick(Cancel As Integer)
Dim PhoneNo As String
If (Me.TelephoneNo <> 0) Then
PhoneNo = Me.TelephoneNo
DoCmd.OpenForm "EntryPhones", , , , acFormEdit, ,
PhoneNo
DoCmd.FindRecord PhoneNo, , True, , True, , True
Else
'Blank record is being added, so
'The "CoWorkerId" needs to be set here
DoCmd.OpenForm "EntryPhones", , , , acFormEdit, , "0-0-0"
DoCmd.GoToRecord , , acNewRec
End If
End Sub
An suggestions or recommendations are greatly appreciated.
Thank you very much.
I have a mainform and a related subform.
On the subform the related records are listed in a tabular
format. The last record in this table is a blank record.
When the user "double-clicks" the blank record, another
edit form appears where the user can enter the data.
My problem is trying to assign a primary key to this new
record, which comes from the mainform.
I've added the primary key field as "hidden fields" to the
mainform and subform.
I've tried capturing the key field into a "global"
variable. I've tried to reference the key field with
Forms!mainform!CustomerId
mainform.CustomerId
I've even tried to set the default of the key field,
through the "properties" window but, no luck.
Here's the code:
Private Sub TelephoneNo_DblClick(Cancel As Integer)
Dim PhoneNo As String
If (Me.TelephoneNo <> 0) Then
PhoneNo = Me.TelephoneNo
DoCmd.OpenForm "EntryPhones", , , , acFormEdit, ,
PhoneNo
DoCmd.FindRecord PhoneNo, , True, , True, , True
Else
'Blank record is being added, so
'The "CoWorkerId" needs to be set here
DoCmd.OpenForm "EntryPhones", , , , acFormEdit, , "0-0-0"
DoCmd.GoToRecord , , acNewRec
End If
End Sub
An suggestions or recommendations are greatly appreciated.
Thank you very much.