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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NotInList Event

Status
Not open for further replies.

laura525

Technical User
Nov 8, 2004
11
0
0
US
Private Sub ClockNo_NotInList(NewData As String, Response As Integer)
Dim cn As Connection
Dim rs As ADODB.Recordset


If MsgBox(NewData & " is not in the selection provided. Would you like to add it?", vbQuestion + vbYesNo, "Unknown Course") = vbYes Then
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset

With rs
.Open "Supervisor", cn, adOpenStatic, adLockPessimistic
.AddNew
.Fields("ClockNo") = StrConv(NewData, vbProperCase)
.Update
.Close
End With

Response = acDataErrAdded

Else
Me.ClockNo.Undo
Response = acDataErrContinue
End If

Set rs = Nothing
Set db = Nothing
End Sub

I am having a problem with this code. When I try to enter data that is not in the list the message pops up. When I click Yes (I would like to add it) it clears the form. I want it to go to the supervisor field so I can add a supervisor to go with the ClockNo.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top