I open a form and prepare to add records:
DoCmd.GoToRecord , , acNewRec
The user adds in fields to the form (like a new SSN). 2 new records are created in 2 existing tables.
Given the SSN, I need to lookup the first and last name from tblEmployee to include them in one of the new records (alas, twas not my database, and yes it is NOT normalized correctly, sigh).
Ideally I thought I could use a DLOOKUP but am getting an error "SaveRecord isn't available now" and I'm pretty sure I've walked over the first DoCmd.GoToRecord,,acNewRec.
Anybody have any other generous thoughts on how I can accomplish this?
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cmdSBNbrClos_Click()
Dim strSQL As String
On Error GoTo Err_cmdSBNbrClos_Click
[SuppressPrintFlag] = chkPrint
[Note1] = txtNote1
[Note2] = txtNote2
[Note3] = txtNote3
[Note4] = txtNote4
[Note5] = txtNote5
Dim varX As Variant
varX = DLookup("[Last Name]", "tblEmployee", "[SSN] = '" & Me.[StaffSSN] & "'")
varX = DLookup("[First Name]", "tblEmployee", "[SSN] = '" & Me.[StaffSSN] & "'")
[EntryDate] = Date
[UpdateDate] = Date
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
The user adds in fields to the form (like a new SSN). 2 new records are created in 2 existing tables.
Given the SSN, I need to lookup the first and last name from tblEmployee to include them in one of the new records (alas, twas not my database, and yes it is NOT normalized correctly, sigh).
Ideally I thought I could use a DLOOKUP but am getting an error "SaveRecord isn't available now" and I'm pretty sure I've walked over the first DoCmd.GoToRecord,,acNewRec.
Anybody have any other generous thoughts on how I can accomplish this?
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cmdSBNbrClos_Click()
Dim strSQL As String
On Error GoTo Err_cmdSBNbrClos_Click
[SuppressPrintFlag] = chkPrint
[Note1] = txtNote1
[Note2] = txtNote2
[Note3] = txtNote3
[Note4] = txtNote4
[Note5] = txtNote5
Dim varX As Variant
varX = DLookup("[Last Name]", "tblEmployee", "[SSN] = '" & Me.[StaffSSN] & "'")
varX = DLookup("[First Name]", "tblEmployee", "[SSN] = '" & Me.[StaffSSN] & "'")
[EntryDate] = Date
[UpdateDate] = Date
DoCmd.RunCommand acCmdSaveRecord