Using Access 2000, I am making a database for my record collection. I want to enter Album titles, Artist names and several other items. I have everything figured out except for the artist names. I'm using a combo box because I want to be able to choose the name from a drop down list but if it's not there, I want to be able to add it right in the Recordings form and not have to go the the artist table. The combo box currently works, I just can't add new entries. I get the following warning:
"The text you entered is not an item on the list. Select an item from the list, or enter text that matches one of the listed items."
According to the help file, I need to use the OnNotInList property and the NotInList event. I'm not sure how to integrate these into my database. Can someone help me? I have the following tables:
Music Categories
Recording Artists
Recordings
Switchboard Items
Tracks
I am using table Recording Artists as a subform in the main form Recordings.
I tried adding the property and event into the visual basic module and I get a "compile error, User-defined Type not Defined" error. Here are my AddToList and NotInList functions.
==========================================
Private Function AddToList(strTable As String, strField As String, _
strData As String) As Integer
' Add item to table
' Returns acDataErrAdded if successful,
' acDataErrDisplay on any error
Dim db As Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "Insert into " & strTable & " (" & strField & ") Values " _
& "(" & conQuote & strData & conQuote & ")"
Set db = CurrentDb
db.Execute strSQL
ExitHere:
AddToList = acDataErrAdded
Exit Function
HandleErr:
AddToList = acDataErrDisplay
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"Form_Recordings.AddToList()"
End Select
Resume ExitHere
End Function
---------------------------------------------------------
Private Sub RecordingArtistID_NotInList(NewData As String, Response As Integer)
' Add category item to list
On Error GoTo HandleErr
If MsgBox("Would you like to add this item to the list?", _
vbYesNo + vbQuestion, "Item not in list") = vbYes Then
Response = AddToList("Recording Artists", "RecordingArtistID", NewData)
Else
Response = acDataErrDisplay
End If
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"Form_Recordings.RecordingArtistID_NotInList"
End Select
Resume ExitHere
Resume
End Sub
"The text you entered is not an item on the list. Select an item from the list, or enter text that matches one of the listed items."
According to the help file, I need to use the OnNotInList property and the NotInList event. I'm not sure how to integrate these into my database. Can someone help me? I have the following tables:
Music Categories
Recording Artists
Recordings
Switchboard Items
Tracks
I am using table Recording Artists as a subform in the main form Recordings.
I tried adding the property and event into the visual basic module and I get a "compile error, User-defined Type not Defined" error. Here are my AddToList and NotInList functions.
==========================================
Private Function AddToList(strTable As String, strField As String, _
strData As String) As Integer
' Add item to table
' Returns acDataErrAdded if successful,
' acDataErrDisplay on any error
Dim db As Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "Insert into " & strTable & " (" & strField & ") Values " _
& "(" & conQuote & strData & conQuote & ")"
Set db = CurrentDb
db.Execute strSQL
ExitHere:
AddToList = acDataErrAdded
Exit Function
HandleErr:
AddToList = acDataErrDisplay
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"Form_Recordings.AddToList()"
End Select
Resume ExitHere
End Function
---------------------------------------------------------
Private Sub RecordingArtistID_NotInList(NewData As String, Response As Integer)
' Add category item to list
On Error GoTo HandleErr
If MsgBox("Would you like to add this item to the list?", _
vbYesNo + vbQuestion, "Item not in list") = vbYes Then
Response = AddToList("Recording Artists", "RecordingArtistID", NewData)
Else
Response = acDataErrDisplay
End If
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, , _
"Form_Recordings.RecordingArtistID_NotInList"
End Select
Resume ExitHere
Resume
End Sub