J
JessiRight77
I am working on a friend's "Song Database." From his main Song form,
he has a subform that lists the names of all the Hymn Books that
contains that Song, and he wants to be able to enter a new hymnal book
if it is not already listed in the drop-down list. The table that
contains the Hymnal Book information (T_Hymnals) has a Hymnal Code
field (HymnalCode) and a Hymnal Name field (HymnalName).
The combo box on the subform is based on a combination of the
HymnalCode ID and HymnalName... the HymnalCode ID is not displayed
because of the column width of 0";2"; the HymnalName is what is
actually shown in the drop-down box.
I searched in the Google Newsgroups for information about the "On Not
In List" event, and found the following code (below) by Dev Ashish, so
I modified it for my friend's situation.
The PROBLEM is: When I "Click Yes to Link," it assigns the new data
into the HymnalCode ID field of the combo box (which is not displayed),
instead of the HymnalName field (which is displayed), so the drop-down
box now contains a blank entry. There doesn't seem to be any way to
enter new data for the actual name of the hymnal... only the HymnalCode
ID.
The Ashish code I am trying to modify is as follows:
Private Sub cbxAEName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Name " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the
current DLSAF?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to
re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("T_Hymnals", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!HymnalCode = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Does anyone know how he can enter new data into the drop-down list if
it is based on a combination of the HymnalCode ID and HymnalName?
Any help would be greatly appreciated.
Jessi
he has a subform that lists the names of all the Hymn Books that
contains that Song, and he wants to be able to enter a new hymnal book
if it is not already listed in the drop-down list. The table that
contains the Hymnal Book information (T_Hymnals) has a Hymnal Code
field (HymnalCode) and a Hymnal Name field (HymnalName).
The combo box on the subform is based on a combination of the
HymnalCode ID and HymnalName... the HymnalCode ID is not displayed
because of the column width of 0";2"; the HymnalName is what is
actually shown in the drop-down box.
I searched in the Google Newsgroups for information about the "On Not
In List" event, and found the following code (below) by Dev Ashish, so
I modified it for my friend's situation.
The PROBLEM is: When I "Click Yes to Link," it assigns the new data
into the HymnalCode ID field of the combo box (which is not displayed),
instead of the HymnalName field (which is displayed), so the drop-down
box now contains a blank entry. There doesn't seem to be any way to
enter new data for the actual name of the hymnal... only the HymnalCode
ID.
The Ashish code I am trying to modify is as follows:
Private Sub cbxAEName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Name " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to associate the new Name to the
current DLSAF?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to
re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("T_Hymnals", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!HymnalCode = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Does anyone know how he can enter new data into the drop-down list if
it is based on a combination of the HymnalCode ID and HymnalName?
Any help would be greatly appreciated.
Jessi