Hello,
I have a NotInList event which runs fine alone, but, when linked to a query that is intended to pull only those offices within a component (two separate tables) the form will go back to the query, in turn going back to the form, and not post the NewData to the table.
Is there a way to get the query to recognize new data being entered and allow it to post after the users clicks yes on the question box?
This is the query that is causing the field to go back to the form:
SELECT tblOffice.OffID, tblOffice.Office, tblOffice.DirID
FROM tblOffice
WHERE (((tblOffice.DirID)=[Forms]![frmPersoPLAY]![cboDir]));
and this is the NotInList Event that works if I take out the WHERE criteria in my query:
Private Sub cboOffice_NotInList(NewData As String, Response As Integer)
Dim strSOL As String
If MsgBox(NewData & " is not currently listed as an office within this Component. Would you like to add this office to the database?", _
vbYesNo + vbQuestion) = vbYes Then
strSQL = "insert into tblOffice (Office) values ('" & NewData & "')"
CurrentDb.Execute strSQL
Response = acDataErrAdded
Else: MsgBox "" & NewData & " Not added"
End If
End Sub
Please, if you know how to work around this issue, let me know. Thanks in advance.
I have a NotInList event which runs fine alone, but, when linked to a query that is intended to pull only those offices within a component (two separate tables) the form will go back to the query, in turn going back to the form, and not post the NewData to the table.
Is there a way to get the query to recognize new data being entered and allow it to post after the users clicks yes on the question box?
This is the query that is causing the field to go back to the form:
SELECT tblOffice.OffID, tblOffice.Office, tblOffice.DirID
FROM tblOffice
WHERE (((tblOffice.DirID)=[Forms]![frmPersoPLAY]![cboDir]));
and this is the NotInList Event that works if I take out the WHERE criteria in my query:
Private Sub cboOffice_NotInList(NewData As String, Response As Integer)
Dim strSOL As String
If MsgBox(NewData & " is not currently listed as an office within this Component. Would you like to add this office to the database?", _
vbYesNo + vbQuestion) = vbYes Then
strSQL = "insert into tblOffice (Office) values ('" & NewData & "')"
CurrentDb.Execute strSQL
Response = acDataErrAdded
Else: MsgBox "" & NewData & " Not added"
End If
End Sub
Please, if you know how to work around this issue, let me know. Thanks in advance.