Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commit row - how to - Access 2007

Status
Not open for further replies.

Dom606

IS-IT--Management
Jul 29, 2007
123
US
Hi everyone,
I have a Tabbed form that has been working fine. Now when I select a specific tab and try to enter a new record, I get the following error:

The value cannot be added to this new row until the row has been committed. Commit the row first, and then try adding the value.

I have no idea how to commit a new row! If someone can tell me how to do that it will be much appreciated.

Here is the code behind the tabbed form, if that helps. The field I am trying to add data to is cboSkillCategory:

Code:
Option Compare Database
Option Explicit

Private Sub cboSkillCategory_AfterUpdate()
    Me.cboSkills = 0
    Me.cboSkills.Requery
    
End Sub

Private Sub cboSkillCategory_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboSkillCategory_NotInList

Dim intAnswer As Integer

intAnswer = MsgBox("Value not in lookup table. Edit table?", vbYesNo, vbQuestion)
    If intAnswer = vbYes Then
        DoCmd.RunCommand acCmdUndo
        DoCmd.OpenForm "frmSkillCategory", acNormal, , , acFormEdit, acDialog
        Response = acDataErrAdded
    Else
        Response = acDataErrContinue
    End If

Exit_cboSkillCategory_NotInList:
    Exit Sub

Err_cboSkillCategory_NotInList:
    MsgBox Err.Description
    Resume Exit_cboSkillCategory_NotInList
End Sub

Private Sub cboSkills_AfterUpdate()
    Me.txtSkill.Requery
End Sub

Private Sub cboSkills_GotFocus()
    If Len(Trim(Nz(cboSkillCategory, "") & "")) = 0 Then
        MsgBox "Please Specify Category first"
        cboSkillCategory.SetFocus
    Else
        Me.cboSkills.Requery
    End If
End Sub

Private Sub cboSkills_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboSkills_NotInList

Dim intAnswer As Integer

intAnswer = MsgBox("Value not in lookup table. Edit table?", vbYesNo, vbQuestion)
    If intAnswer = vbYes Then
        DoCmd.RunCommand acCmdUndo
        DoCmd.OpenForm "frmSkilltblSkills", acNormal, , , acFormEdit, acDialog
        Response = acDataErrAdded
    Else
        Response = acDataErrContinue
    End If

Exit_cboSkills_NotInList:
    Exit Sub

Err_cboSkills_NotInList:
    MsgBox Err.Description
    Resume Exit_cboSkills_NotInList
End Sub

'------------------------------------------------------------
' cmdPreviewReport_Click
'
'------------------------------------------------------------
Private Sub cmdPreviewReport_Click()
On Error GoTo cmdPreviewReport_Click_Err
    
    Forms![frmEmployee Details].Visible = False
    DoCmd.OpenReport "rptSillEvaluation", acViewPreview, "", "", acNormal
  

cmdPreviewReport_Click_Exit:
    Exit Sub

cmdPreviewReport_Click_Err:
    MsgBox Error$
    Resume cmdPreviewReport_Click_Exit


End Sub

'Private Sub Form_Dirty(Cancel As Integer)
'If Me.Dirty Then Me.Dirty = False
'End Sub

Private Sub Form_Load()
If IsNull(cboSkillCategory) Then
  cboSkillCategory = Me.cboSkillCategory.ItemData(0)
  Call cboSkillCategory_AfterUpdate
End If
End Sub

Private Sub Form_Current()
    Me.cboSkills.Requery
End Sub
 
How are ya Dom606 . . .

There's alot that can be asked about this (espcially not knowing the setup), but as as a first stab:
TheAceMan1 said:
[blue]Are you entering a new record in a subform without entering data in the new record of the mainform?[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks for the reply Ace Man. I am still baffeled. I have a tabbed form with 5 tabs. Each tab has a form. The one that is causing me problems is listed above. The first field is cboSkillCategory. When I click on it, the drop down displays the correct data. As soon as I select one of the options, the commit error pops up.
 
Dom606 . . .

Your talking [blue]subForms[/blue] here ... not forms.

Are the subforms linked to the mainform?

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
How are ya kronar . . .

I keep getting the impression your using an [blue]ADO Data Set.[/blue] Let me know if this true.

In any case, referencing the subform depends on which code module the code is running in. If its running in the mainform try:
Code:
[blue]   If Me.Dirty Then Me.Dirty = False [green]'Save the current record[/green]
   [TimebyDate].[purple][b]Form[/b][/purple].Requery[/blue]
... else if its running in the subform try:
Code:
[blue]   If Me.Dirty Then Me.Dirty = False 'Save the current record[/green]
   Me.Requery[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top