Here is where I am at. When I input a new number into the combobox I get strMessage = "Add " & NewData & " to list?" and when selecting Yes moves the focus to the cboDept to initiated data input on a new record. Next when I select <New Record> from the combobox
the focus moves to txtAssessionNumber. I will change this focus to match the other. Both of these appear to be working.
What appears not to be working is when I input a known Assession Number into the combobox I get the Warning Message: No matching record. I have in my table fields ID (Primary Key, Indexed Yes (No Duplicates)), MRN (Indexed Yes (Duplicates OK)), and AssessionNumber
(Indexed Yes (No Duplicates)). I currently have this code in my cboGoToAssession event procedure:
Private Sub cboGotoAssession_AfterUpdate()
Const MESSAGETEXT = "No matching record"
Dim ctrl As Control
Set ctrl = Me.ActiveControl
If Not IsNull(ctrl) Then
If ctrl = 0 Then
' go to new record and move focus to Assession control
' DoCmd.GoToRecord acForm, Me.Name, acNewRec (Tried but did not work)
DoCmd.GoToRecord , , acNewRec
Me.txtAssessionNumber.SetFocus
Else
With Me.RecordsetClone
.FindFirst "ID = " & ctrl
If Not .NoMatch Then
' go to record by synchronizing bookmarks
Me.Bookmark = .Bookmark
Else
MsgBox MESSAGETEXT, vbInformation, "Warning"
End If
End With
End If
End If
End Sub
Private Sub cboGotoAssession_NotInList(NewData As String, Response As Integer)
Dim ctrl As Control
Dim strMessage As String
Set ctrl = Me.ActiveControl
strMessage = "Add " & NewData & " to list?"
'if user confirms insert, move form to new record
' and insert values into AssessionNumber control
If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
Response = acDataErrContinue
ctrl.Undo
DoCmd.GoToRecord , , acNewRec
Me.cboGoToAssession = NewData
Else
Response = acDataErrContinue
ctrl.Undo
End If
End Sub
Can you see anything I have done wrong when I input a known Assession Number into the cboGoToAssession what would make a No Matching record? I have tried I think every recommendation you have made. This is the only piece not working. I have reviewed your
findrecord example over and over. See no difference in what I have attempted.
Sorry for the continued questions, I am just about there.
Thanks again for all your help.
Kerry