padlocked17
Registered User.
- Local time
- Today, 07:59
- Joined
- Aug 29, 2007
- Messages
- 276
I've got the following code and I'm running into an issue with moving to the record. For some reason it isn't selecting and going to the correct record.
Any suggestions on how to use the bookmark here?
Any suggestions on how to use the bookmark here?
Code:
Option Compare Database
Private Sub Form_Current()
'When the form loads, hide everything except the combo box
If Me.cboSelectStudent & "" = "" Then
Me.SSN.Visible = False
Me.LastName.Visible = False
Me.FirstName.Visible = False
Me.MI.Visible = False
Me.cboRankID.Visible = False
Me.cboUnitID.Visible = False
Me.StatusID.Visible = False
Me.Status.Visible = False
Me.SemsPro.Visible = False
Else
Me.SSN.Visible = True
Me.LastName.Visible = True
Me.FirstName.Visible = True
Me.MI.Visible = True
Me.cboRankID.Visible = True
Me.cboUnitID.Visible = True
Me.StatusID.Visible = True
Me.Status.Visible = True
Me.SemsPro.Visible = True
End If
'Set the focus on the combo box so the focus isn't on a hidden field
Me.cboSelectStudent.SetFocus
End Sub
Private Sub cboSelectStudent_AfterUpdate()
'When a selection is made in the combo box, make fields visible
If Me.cboSelectStudent & "" = "" Then
Me.SSN.Visible = False
Me.LastName.Visible = False
Me.FirstName.Visible = False
Me.MI.Visible = False
Me.cboRankID.Visible = False
Me.cboUnitID.Visible = False
Me.StatusID.Visible = False
Me.SemsPro.Visible = False
Else
Me.SSN.Visible = True
Me.LastName.Visible = True
Me.FirstName.Visible = True
Me.MI.Visible = True
Me.cboRankID.Visible = True
Me.cboUnitID.Visible = True
Me.StatusID.Visible = True
Me.SemsPro.Visible = True
End If
End Sub
Private Sub cboSelectStudent_Change()
Dim class As Integer
class = Me!cboSelectStudent
DoCmd.ShowAllRecords
Me!txtStudentID.SetFocus
DoCmd.FindRecord class
End Sub
'******************************************
'
'I need to get the Bookmark to pull up the record
'
'
'******************************************
Private Sub SSN_LostFocus()
Dim SSN As String
Dim ssnLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SSN = Me.SSN.Value
ssnLinkCriteria = "[SSN]=" & "'" & SSN & "'"
'Check tblstudents table for duplicate SSN
If DCount("SSN", "tblStudents", _
ssnLinkCriteria) > 0 Then
'Undo the duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Student Number " _
& SSN & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Make the combo box visible
Me.cboSelectStudent.Visible = True
'Go to record of original Student Number
rsc.FindFirst ssnLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub