NotInList Issue

T

TeeSee

In the following code I INSERT the last name into the table and then
open it in edit mode to add the remaining information. When I close
the form I receive the message "The text you entered isn't an item in
the list.
LimitToList = yes
Could someone suggest a remedy please?
Could the row source query have a bearing on the problem?

Private Sub cboContactID_NotInList(NewData As String, Response As
Integer)

Dim strSQL As String
Dim x As Integer

x = MsgBox("Do you want to add this value to the list?", vbYesNo)
If x = vbYes Then
strSQL = "Insert Into tblContacts ([txtLastName]) values ('" &
NewData & "')"
' MsgBox strsql

CurrentDb.Execute strSQL, dbFailOnError



Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
DoCmd.OpenForm "frmContactsAdd", acNormal, , "[txtLastName] ='" &
NewData & "'", acFormEdit, acDialog
End Sub
 
T

TeeSee

In the following code I INSERT the last name into the table and then
open it in edit mode to add the remaining information. When I close
the form I receive the message "The text you entered isn't an item in
the list.
LimitToList = yes
Could someone suggest a remedy please?
Could the row source query have a bearing on the problem?

Private Sub cboContactID_NotInList(NewData As String, Response As
Integer)

Dim strSQL As String
Dim x As Integer

    x = MsgBox("Do you want to add this value to the list?", vbYesNo)
    If x = vbYes Then
        strSQL = "Insert Into tblContacts ([txtLastName]) values ('" &
NewData & "')"
     '   MsgBox strsql

        CurrentDb.Execute strSQL, dbFailOnError

        Response = acDataErrAdded
    Else
        Response = acDataErrContinue
    End If
   DoCmd.OpenForm "frmContactsAdd", acNormal, , "[txtLastName] ='" &
NewData & "'", acFormEdit, acDialog
End Sub

Sorry folks I forgot to add to the end of the post ...... as follows

I had already recently asked this question and Arvin Meyer was good
enough to respond with "Moving between form and subform, or visa-
versa, saves the record being
edited. If there is anything which denies that save, like an unmet
validation rule, an error occurs."

As yet I do not have any validation rules in place, hence my question
about the RowSource. Does the RowSource SQL actually become a
"validation rule" in itself.

Are there any "tricks" (methods) to finding where my problem would
lie.

Thanks as always!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top