Private Sub cboAuthor_NotInList(NewData As String, Response As Integer)
On Error GoTo cboAuthor_NotInList_Err
If MsgBox("The author " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Appell Library") = vbYes Then
DoCmd.OpenForm "frmAuthorEntry", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
Else
MsgBox "Please choose an author from the list." _
, vbInformation, "Appell Library"
Response = acDataErrContinue
End If
cboAuthor_NotInList_Exit:
Exit Sub
cboAuthor_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboAuthor_NotInList_Exit
End Sub
Private Sub Something_NotInList(NewData As String, Response As Integer)
Dim db As Database
Dim LSQL As String
Dim LResponse As Integer
Dim ctl As Control
Dim Medid As Long
On Error GoTo Err_Execute
Set ctl = Me!somebox2
Medid = Me!somebox
Set db = CurrentDb()
LSQL = "insert into Sometable (somecolumn,somecolumn2) values ('" & Medid & "','" & NewData & "')"
db.Execute LSQL, dbFailOnError
Set db = Nothing
Response = acDataErrAdded
On Error GoTo 0
Exit Sub
Err_Execute:
Response = acDataErrContinue
ctl.Undo
MsgBox "Action failed"
End Sub
DoCmd.OpenForm "frmAuthorEntry", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
[B]me.cboAuthor.requery ' add line here[/B]
Else
MsgBox "Please choose an author from the list." _
, vbInformation, "Appell Library"
Response = acDataErrContinue
End If
cboAuthor_NotInList_Exit:
Exit Sub
cboAuthor_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboAuthor_NotInList_Exit
End Sub
Private Sub Form_Load()
'Dim Args As Variant
Dim Args() As String
If Not IsNull(Me.OpenArgs) Then
Args() = Split(Me.OpenArgs, ",")
Me.AuthorLastName = Args(0)
Me.AuthorFirstName = Args(1)
End If
Form_frmBookInfo.cboAuthor = ""
End Sub
uncle joe - thanks, i've tried that too. i just retried it to make sure.
after i hit the button on the popup form to close the popup, it closes the popup, then it tells me i need to save the current field before the requery action and gives me the standard access error message.
that's where i am getting so confused as well. i don't understand how to save the record. i've read that access automatically saves when you advance to a new record, but i've tried that too and still get the same thing.
the new data is ALWAYS added to the combo box, though. that was the easy part.
the hard part is trying to get access to see that it is there without having to reselect it.