Hi Everyone.
I have a subform (call listing subform) that is on a form (contacts). This subform is shown as a continuous form. This form has "allowadditions" disabled. This subform is, of course, bound to a table.
To add data to this form/table, I have a button on the subform that opens an unbound form where I can enter the data. Then I click on a button that has the following code to get the data from this unbound form to the call listing subform.
The problem is that, as is, I get the error "cannot go to that record" when Access gets to "DoCmd.GoToRecord , , acNewRec", but if I take that line out, it tries to paste the new entry over an older one.
What am I missing
Thanks
Mafhobb
I have a subform (call listing subform) that is on a form (contacts). This subform is shown as a continuous form. This form has "allowadditions" disabled. This subform is, of course, bound to a table.
To add data to this form/table, I have a button on the subform that opens an unbound form where I can enter the data. Then I click on a button that has the following code to get the data from this unbound form to the call listing subform.
Code:
Private Sub Add_Call_Click()
On Error GoTo err_Click
'Data conditioning
Me.SKUEntry.SetFocus
If Me.SKUEntry.Text = "" Then
MsgBox "Please enter a SKU Number."
Exit Sub
End If
Me.SubjectEntry.SetFocus
If Me.SubjectEntry.Text = "" Then
MsgBox "Please enter a Subject."
Exit Sub
End If
Me.StaffEntry.SetFocus
If Me.StaffEntry.Text = "" Then
MsgBox "Please enter a Staff Name."
Exit Sub
End If
'Allow additions to other form
Forms![Contacts]![Call Listing Subform].Form.AllowAdditions = Not Forms![Contacts]![Call Listing Subform].Form.AllowAdditions
'go to new record on other form
DoCmd.GoToRecord , , acNewRec
'Set focus and assign values
Me.SKUEntry.SetFocus
Forms![Contacts]![Call Listing Subform].Form![SKU] = Me.SKUEntry.Text
MsgBox "New SKU done"
Me.SubjectEntry.SetFocus
Forms![Contacts]![Call Listing Subform].Form![Subject] = Me.SubjectEntry.Text
MsgBox "New Subject done"
Me.StaffEntry.SetFocus
Forms![Contacts]![Call Listing Subform].Form![Staff] = Me.StaffEntry.Text
MsgBox "New Staff done"
Me.Details.SetFocus
If Me.Details.Text = "" Then
MsgBox "No call details to enter"
Else
Forms![Contacts]![Call Details Subform].Form![Notes] = Me.Details.Text
MsgBox "Added call details"
End If
'Deny additions to other form
Forms![Contacts]![Call Listing Subform].Form.AllowAdditions = Not Forms![Contacts]![Call Listing Subform].Form.AllowAdditions
'Close this form
DoCmd.Close
Exit Sub
err_Click:
MsgBox Err.Description
Exit Sub
End Sub
The problem is that, as is, I get the error "cannot go to that record" when Access gets to "DoCmd.GoToRecord , , acNewRec", but if I take that line out, it tries to paste the new entry over an older one.
What am I missing
Thanks
Mafhobb