K
Kirkpatti
Hello,
I've got a bibliography data base I'm trying to set up and would like to
enter a name, "John Smith" into my form and have it add an entry into my
Authors table as Column 1 - John, Column 2, Smith.
Also, there are sometimes mulitple authors on any given paper. How can I
enter mulitple authors for the same paper?
Below is the VBA, SQL code I've been trying to work from. I get an error,
"Number of query values and destination fields are not the same" when I try
to run it. But it still would 't solve the mulitple author problem even if
it worked.
Private Sub Authors_NotInList(NewData As String, Response As Integer)
On Error GoTo Authors_NotInList_Err
Dim KpAnswer As Integer
Dim KpSQL As String
KpAnswer = MsgBox("The author " & Chr(34) & NewData & _
Chr(34) & " is not currently an option." & vbCrLf & _
"Would you like to add him or her to the list now?" _
, vbQuestion + vbYesNo, "New Author?")
If KpAnswer = vbYes Then
KpSQL = "INSERT INTO [Authors] ([First Name], [Last Name])" & _
"VALUES('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL KpSQL
DoCmd.SetWarnings True
MsgBox "This author has been added to the list." _
, vbInformation, "New Author"
Response = acDataErrAdded
Else
MsgBox "Please choose an author from the list." _
, vbInformation, "New Author"
Response = acDataErrContinue
End If
Authors_NotInList_Exit:
Exit Sub
Authors_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Authors_NotInList_Exit
End Sub
Thanks!
I've got a bibliography data base I'm trying to set up and would like to
enter a name, "John Smith" into my form and have it add an entry into my
Authors table as Column 1 - John, Column 2, Smith.
Also, there are sometimes mulitple authors on any given paper. How can I
enter mulitple authors for the same paper?
Below is the VBA, SQL code I've been trying to work from. I get an error,
"Number of query values and destination fields are not the same" when I try
to run it. But it still would 't solve the mulitple author problem even if
it worked.
Private Sub Authors_NotInList(NewData As String, Response As Integer)
On Error GoTo Authors_NotInList_Err
Dim KpAnswer As Integer
Dim KpSQL As String
KpAnswer = MsgBox("The author " & Chr(34) & NewData & _
Chr(34) & " is not currently an option." & vbCrLf & _
"Would you like to add him or her to the list now?" _
, vbQuestion + vbYesNo, "New Author?")
If KpAnswer = vbYes Then
KpSQL = "INSERT INTO [Authors] ([First Name], [Last Name])" & _
"VALUES('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL KpSQL
DoCmd.SetWarnings True
MsgBox "This author has been added to the list." _
, vbInformation, "New Author"
Response = acDataErrAdded
Else
MsgBox "Please choose an author from the list." _
, vbInformation, "New Author"
Response = acDataErrContinue
End If
Authors_NotInList_Exit:
Exit Sub
Authors_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Authors_NotInList_Exit
End Sub
Thanks!