I
Ian Baker
Hi
I have 2 problems but fixing 1 may fix the other.
In 2003 I am using a form that has a combo box, a tab control and a subform
on the tab control. When an entry is entered into the combo box it checks to
see if the entry already exists, and if it does, advises the user that the
entry is already in the system and would they like to view the record. If
they select yes the existing entry is displayed. I also require the subform
in this instance as well as when navigating between each record to go to a
new record at the bottom of the subform displaying above it all previous
records.
My code so far is:
- the BeforeUpdate property of the cbo on the main form
Private Sub ctlContactName_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "ContactName = '" & ctlContactName & "'"
If rst.NoMatch = False Then
If MsgBox("This contact is already in the system. Do you wish to
view this " & _
"contact's details.", vbYesNo, "Existing Contact") = vbYes Then
Cancel = True
Me.Undo
Me.Bookmark = rst.Bookmark
Else
Cancel = True
Me.Undo
End If
End If
rst.Close
Set rst = Nothing
End Sub
- The OnCurrent property of the form
Private Sub Form_Current()
Me!subContactActivity.SetFocus
Me!subContactActivity.Form!ctlActivityDate.SetFocus
DoCmd.GoToRecord , , acNewRec
Me!ctlContactName.SetFocus
End Sub
The subform problem is that it does go to the new record but when there are
more then 13 records it jumps the page and only displays the new record and
I have to scroll up to see more. I need it to show the new record at the
bottom but also filling the subform up with previous records.
The other problem is that when I use the procedure in the first code snippet
above I get an error when it hits the Form_Current() procedure above at the
Me!subContactActivity.SetFocus
line:
2108 - You must save the field before you execute the GoToControl action,
the GoToControl method, or the SetFocus method.
Clicking Help on the dialogue box only presents me with an empty help
window.
I know I must be doing something wrong but for the life of me I can't see
where so your help is as always greatly appreciated.
I have 2 problems but fixing 1 may fix the other.
In 2003 I am using a form that has a combo box, a tab control and a subform
on the tab control. When an entry is entered into the combo box it checks to
see if the entry already exists, and if it does, advises the user that the
entry is already in the system and would they like to view the record. If
they select yes the existing entry is displayed. I also require the subform
in this instance as well as when navigating between each record to go to a
new record at the bottom of the subform displaying above it all previous
records.
My code so far is:
- the BeforeUpdate property of the cbo on the main form
Private Sub ctlContactName_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "ContactName = '" & ctlContactName & "'"
If rst.NoMatch = False Then
If MsgBox("This contact is already in the system. Do you wish to
view this " & _
"contact's details.", vbYesNo, "Existing Contact") = vbYes Then
Cancel = True
Me.Undo
Me.Bookmark = rst.Bookmark
Else
Cancel = True
Me.Undo
End If
End If
rst.Close
Set rst = Nothing
End Sub
- The OnCurrent property of the form
Private Sub Form_Current()
Me!subContactActivity.SetFocus
Me!subContactActivity.Form!ctlActivityDate.SetFocus
DoCmd.GoToRecord , , acNewRec
Me!ctlContactName.SetFocus
End Sub
The subform problem is that it does go to the new record but when there are
more then 13 records it jumps the page and only displays the new record and
I have to scroll up to see more. I need it to show the new record at the
bottom but also filling the subform up with previous records.
The other problem is that when I use the procedure in the first code snippet
above I get an error when it hits the Form_Current() procedure above at the
Me!subContactActivity.SetFocus
line:
2108 - You must save the field before you execute the GoToControl action,
the GoToControl method, or the SetFocus method.
Clicking Help on the dialogue box only presents me with an empty help
window.
I know I must be doing something wrong but for the life of me I can't see
where so your help is as always greatly appreciated.