Problem Adding Record to subform on tab control

A

Amy@Ioline

Hi there:

I have a subform on a tab control. I'm trying to program an Add Record
button to insert a new record in the table linked to the subform. I'm getting
the following error message:

"You can't go the specified record."

Any ideas why this won't work? (The table structure and event procedure code
is below.)

I have a second subform that works just fine. The only difference between
the two is that the one that works uses a table with an autonumber key field.
Could this be related to my problem? If so, what's the fix?

...................................................
TABLE STRUCTURE: Promo_Log

(* indicates key field)

PROMO_ID Number *
CONTACT_ID Number * (=link to parent form)
Respond_Date Date/Time *
Response Text


...................................................
EVENT PROCEDURE CODE: Promo_Form

Option Compare Database
Option Explicit

Private Sub MakeFormReadOnly()
Me.AllowAdditions = False 'Do not allow new record to be added
Me.AllowDeletions = False
Me.AllowEdits = False
Me.BTNAddRecord.Enabled = True
Me.BTNEditRecord.Enabled = True
Me.BTNSaveRecord.Enabled = False

End Sub
Private Sub BTNAddRecord_Click()
On Error GoTo Err_BTNAddRecord_Click

Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True
DoCmd.GoToRecord , , acNewRec
Me.PROMO_ID.SetFocus
Me.BTNEditRecord.Enabled = False
Me.BTNSaveRecord.Enabled = True

Exit_BTNAddRecord_Click:
Exit Sub

Err_BTNAddRecord_Click:
MsgBox Err.Description
Resume Exit_BTNAddRecord_Click

End Sub

Private Sub BTNSaveRecord_Click()
On Error GoTo Err_BTNSaveRecord_Click

Me.CMB_Response.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MakeFormReadOnly

Exit_BTNSaveRecord_Click:
Exit Sub

Err_BTNSaveRecord_Click:
MsgBox Err.Description
Resume Exit_BTNSaveRecord_Click

End Sub

Private Sub BTNEditRecord_Click()
Me.AllowAdditions = False 'Do not allow new record to be added
Me.AllowEdits = True 'Allow Record to be edited
Me.AllowDeletions = False
CMB_Response.SetFocus 'Move cursor to Organization Name field
Me.BTNEditRecord.Enabled = False
Me.BTNAddRecord.Enabled = False
Me.BTNSaveRecord.Enabled = True
End Sub

Private Sub Form_AfterUpdate()
MakeFormReadOnly 'Prevent Record from being edited
End Sub

Private Sub Form_Current()
MakeFormReadOnly
End Sub
Private Sub BTN_Promo_List_Click()
On Error GoTo Err_BTN_Promo_List_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Promo_List_Form"

stLinkCriteria = "[Promo_ID]=" & Me![PROMO_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_BTN_Promo_List_Click:
Exit Sub

Err_BTN_Promo_List_Click:
MsgBox Err.Description
Resume Exit_BTN_Promo_List_Click

End Sub
Private Sub BTN_View_Promos_Click()
On Error GoTo Err_BTN_View_Promos_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Promo_List_Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_BTN_View_Promos_Click:
Exit Sub

Err_BTN_View_Promos_Click:
MsgBox Err.Description
Resume Exit_BTN_View_Promos_Click

End Sub
...............................................

Thanks for your help.
- Amy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top