Split "Firstname Lastname" text box into two columns, Multiple Aut

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!
 
B

Bob Hairgrove

KpSQL = "INSERT INTO [Authors] ([First Name], [Last Name])" & _
"VALUES('" & NewData & "');"

Obviously, this doesn't work because the insert statement is expecting two items
and you are only giving it one. But why not design your form so that the user
can enter the last name into one field and the first name into another?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top