I have this code in a form. I do not know why when the table is empty, I mean when is a new record the tab goes to the second field that is a date. Is there any way to adjust this code so that if it is a new record it run the code accordingly. Open the form and get focus to CboNameExam?
I work on Windows XP and Access 2007
Private Sub BtnAddResultExam_Click()
On Error GoTo ErrTrap
DoCmd.RunCommand acCmdRecordsGoToNew
Me.CboNameExam.SetFocus
Me.CboName.Dropdown
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox err.Number & " - " & err.Description
Resume ExitPoint
End Sub
I also have the following code on current because I do not want user goes to new record in navigation button. I want it press NewRecord button.
Private Sub Form_Current()
On Error GoTo ErrTrap
Dim rsClone As Recordset
Set rsClone = Me.RecordsetClone
If Me.NewRecord = True Then
Me.CboNameExam.SetFocus
Me!cmdNext.Enabled = False
Me!cmdPrevious.Enabled = True
Me!cmdFirst.Enabled = True
Me!cmdLast.Enabled = True
ElseIf rsClone.Bookmarkable = True Then
rsClone.Bookmark = Me.Bookmark
rsClone.MovePrevious
cmdFirst.Enabled = Not (rsClone.BOF)
cmdPrevious.Enabled = Not (rsClone.BOF)
rsClone.MoveNext
rsClone.MoveNext
cmdNext.Enabled = Not (rsClone.EOF)
cmdLast.Enabled = Not (rsClone.EOF)
rsClone.MovePrevious
End If
rsClone.Close
Me.CountRecords = " "
If Not IsError(Me.CurrentRecord) Then
If Not IsError(Recordset.RecordCount) Then
Me.CountRecords = [CurrentRecord] & " de " & Format(Recordset.RecordCount, "#,##0")
End If
End If
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox err.Number & " - " & err.Description
Resume ExitPoint
End Sub
Tks very much for your help.
I work on Windows XP and Access 2007
Private Sub BtnAddResultExam_Click()
On Error GoTo ErrTrap
DoCmd.RunCommand acCmdRecordsGoToNew
Me.CboNameExam.SetFocus
Me.CboName.Dropdown
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox err.Number & " - " & err.Description
Resume ExitPoint
End Sub
I also have the following code on current because I do not want user goes to new record in navigation button. I want it press NewRecord button.
Private Sub Form_Current()
On Error GoTo ErrTrap
Dim rsClone As Recordset
Set rsClone = Me.RecordsetClone
If Me.NewRecord = True Then
Me.CboNameExam.SetFocus
Me!cmdNext.Enabled = False
Me!cmdPrevious.Enabled = True
Me!cmdFirst.Enabled = True
Me!cmdLast.Enabled = True
ElseIf rsClone.Bookmarkable = True Then
rsClone.Bookmark = Me.Bookmark
rsClone.MovePrevious
cmdFirst.Enabled = Not (rsClone.BOF)
cmdPrevious.Enabled = Not (rsClone.BOF)
rsClone.MoveNext
rsClone.MoveNext
cmdNext.Enabled = Not (rsClone.EOF)
cmdLast.Enabled = Not (rsClone.EOF)
rsClone.MovePrevious
End If
rsClone.Close
Me.CountRecords = " "
If Not IsError(Me.CurrentRecord) Then
If Not IsError(Recordset.RecordCount) Then
Me.CountRecords = [CurrentRecord] & " de " & Format(Recordset.RecordCount, "#,##0")
End If
End If
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox err.Number & " - " & err.Description
Resume ExitPoint
End Sub
Tks very much for your help.