A
alipscomb
I am creating a library catalog DB where the main table, “bookTable†includes
relevant book fields. One such field is the publisher’s name, “Publisher.â€
Publisher is a combo box that looks-up publisherTable, which has an
AutoNumber ID and a Publisher field. On my new book entry form I want to
allow the user to add a new value to the Publisher combo box, populating the
original publisherTable as well. I added code under the “On Not in Listâ€
event, but it seems the event does not execute the code. I only get the "The
text you entered isn't an item in the list" error, but that’s all that
happens. I am creating this DB in Access 2007, but I have successfully used
this functionality for many instances in another DB using Access 2000. I’m
not sure if there is something I’m missing in Access 2007. Any help Is
appreciated. The Publisher field’s table and form properties follow, as well
as the VB code:
The Publisher properties in the table are as follows:
Row Source Type=Table/Query
Row Source=SELECT publisherTable.PublisherID, publisherTable.Publisher FROM
publisherTable;
Bound Column=1
Column Count=2
Column Widths=0â€;1â€
LimitToList=Yes
The Publisher form properties:
Row Source Type=Table/Query
Row Source=SELECT publisherTable.PublisherID, publisherTable.Publisher FROM
publisherTable;
Bound Column=1
Column Count=2
Column Widths=0â€;1â€
LimitToList=Yes
Auto Expand=Yes
On Not in List=[Event Procedure]
VB Code:
Private Sub Publisher_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As DAO.Recordset
Dim db As DAO.Database
strMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Publisher") Then
Response = acDataErrDisplay
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("publisherTable")
rst.AddNew
rst("Publisher") = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
relevant book fields. One such field is the publisher’s name, “Publisher.â€
Publisher is a combo box that looks-up publisherTable, which has an
AutoNumber ID and a Publisher field. On my new book entry form I want to
allow the user to add a new value to the Publisher combo box, populating the
original publisherTable as well. I added code under the “On Not in Listâ€
event, but it seems the event does not execute the code. I only get the "The
text you entered isn't an item in the list" error, but that’s all that
happens. I am creating this DB in Access 2007, but I have successfully used
this functionality for many instances in another DB using Access 2000. I’m
not sure if there is something I’m missing in Access 2007. Any help Is
appreciated. The Publisher field’s table and form properties follow, as well
as the VB code:
The Publisher properties in the table are as follows:
Row Source Type=Table/Query
Row Source=SELECT publisherTable.PublisherID, publisherTable.Publisher FROM
publisherTable;
Bound Column=1
Column Count=2
Column Widths=0â€;1â€
LimitToList=Yes
The Publisher form properties:
Row Source Type=Table/Query
Row Source=SELECT publisherTable.PublisherID, publisherTable.Publisher FROM
publisherTable;
Bound Column=1
Column Count=2
Column Widths=0â€;1â€
LimitToList=Yes
Auto Expand=Yes
On Not in List=[Event Procedure]
VB Code:
Private Sub Publisher_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As DAO.Recordset
Dim db As DAO.Database
strMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Publisher") Then
Response = acDataErrDisplay
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("publisherTable")
rst.AddNew
rst("Publisher") = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub