From: Alaska1 on
Thank you. I got the code to work. I did not like the fact the table name
and field name were the same. The feature that Access 2007 offers is nice
that you do not have to code. I am working with Access 2003. Thank you to
both for all your help.

"Tom Wickerath" wrote:

> Yes, I use the combo box not-in-list procedures in lots of databases that I
> work on. Access 2007 does have a nice feature that allows one to implement
> this functionality without any code, but most of my development work is still
> based on using Access 2003. I have an old sample posted on the Seattle Access
> User's group site, here:
>
> http://www.seattleaccess.org/downloads.htm
>
> Scoll down to the bottom of the page. My sample is currently the fifth one
> from the bottom:
> Not In List - Detailed Instructions by Tom Wickerath
>
> I just tried the code that you indicated does not work in the 2003 version
> of Northwind, using the CategoryID combo box on the Products form. This code
> works fine for me. What type of error are you getting (Error number and
> description)? Could you be battling a MISSING reference error? Does your VBA
> project compile without any errors?
>
>
> Tom Wickerath
> Microsoft Access MVP
> http://www.accessmvp.com/TWickerath/
> __________________________________________
>
> "Alaska1" wrote:
>
> > Hi Tom,
> >
> > Thank you. Have you tried any of them. I am using
> >
> > Private Sub CategoryID_NotInList(NewData As String, Response As Integer)
> > Dim strTmp As String
> >
> > 'Get confirmation that this is not just a spelling error.
> > strTmp = "Add '" & NewData & "' as a new product category?"
> > If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in
> > list") = vbYes Then
> >
> > 'Append the NewData as a record in the Categories table.
> > strTmp = "INSERT INTO Categories ( CategoryName ) " & _
> > "SELECT """ & NewData & """ AS CategoryName;"
> > DBEngine(0)(0).Execute strTmp, dbFailOnError
> >
> > 'Notify Access about the new record, so it requeries the combo.
> > Response = acDataErrAdded
> > End If
> > End Sub
> >
> > But it does not like the code DBEngine(0)(0).Execute strTmp, dbFailOnError
> >
> > keeps giving me an error.
> >
> > I will say hi to Sarah.
First  |  Prev  | 
Pages: 1 2
Prev: cc
Next: Option Button Question