G
Guest
Hey out there,
I am having trouble getting Access to insert new entries into a table from
the main form. I found this VBA code online that does what I want and all of
the lines seem to run individually in the test window, but somehow, the code
does not run as a whole. Anybody see what I've done wrong?
Thanks a million, code below...
Option Compare Database
Private Sub Status_of_Publication_NotInList(NewData As String, Response As
Integer)
On Error GoTo Status_of_Publication_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The status," & Chr(34) & NewData & Chr(34) & "is not
an option currently." & vbCrLf & "Would you like to add it to the list now?",
vbYesNo + vbQuestion, "Oh, No, You Didn't!")
If intAsnwer = vbYes Then
strSQL = "INSERT INTO[Status of Publication](Status of Publication)"
+ "VALUES ('" & NewData & "');"
DoCmd.RunSQL strSQL
MsgBox "The status category has been added to the list.",
vbInformation, "Way to be, yo!"
Response = acDataErrAdded
Else
MsgBox "Please Choose a status category from the list.",
vbInformation, "You know you want to."
Response = acDataErrContinue
End If
Status_of_Publication_NotInList_Exit:
Exit Sub
Status_of_Publication_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Status_of_Publication_NotInList_Exit
End Sub
I am having trouble getting Access to insert new entries into a table from
the main form. I found this VBA code online that does what I want and all of
the lines seem to run individually in the test window, but somehow, the code
does not run as a whole. Anybody see what I've done wrong?
Thanks a million, code below...
Option Compare Database
Private Sub Status_of_Publication_NotInList(NewData As String, Response As
Integer)
On Error GoTo Status_of_Publication_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The status," & Chr(34) & NewData & Chr(34) & "is not
an option currently." & vbCrLf & "Would you like to add it to the list now?",
vbYesNo + vbQuestion, "Oh, No, You Didn't!")
If intAsnwer = vbYes Then
strSQL = "INSERT INTO[Status of Publication](Status of Publication)"
+ "VALUES ('" & NewData & "');"
DoCmd.RunSQL strSQL
MsgBox "The status category has been added to the list.",
vbInformation, "Way to be, yo!"
Response = acDataErrAdded
Else
MsgBox "Please Choose a status category from the list.",
vbInformation, "You know you want to."
Response = acDataErrContinue
End If
Status_of_Publication_NotInList_Exit:
Exit Sub
Status_of_Publication_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Status_of_Publication_NotInList_Exit
End Sub