not in list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've been using this nice little code to add items to combo boxes that worked
great until I made a change to the way the table was named. I'd also like to
add that our office just upgraded from Office 97 to Office XP (in case this
makes a difference).

the code that worked great until now:
......
strSql = "insert Into tblName ([feildName]) values " & "('" & NewData & "')"
stLinkCriteria = "[feildName] = '" & Me.comboName.Text & "'"
if x = vbYes then
CurrentDb.Execute strSql, dbFailOnError
DoCmd.OpenForm "formName", , , stLinkCriteria
Response = acDataErrAdded
Else: Response = acDataErrContinue
end if

what I've done different:
I've changed the table name by request from - tblRelDetails
to - tbl Occurrence Details

I've changed the code to reflect this and enclosed the table name in []

I keep getting an error for the strSql Line and can't figure out why this is
happening.
Does anyone have any suggestions? Would be much appreciated.
 
Since your table name now includes spaces, make sure it is enclosed in
brackets:
"insert Into [tbl Occurrence Details]..."

HTH,
 
nm, I figured out where my problem was, which leads me to my next question...

orignaly the primary key field was an autonumber, but I had to import the
tables from an old database that I made in a97. Because of a large number of
related fields, I needed to keep all the data intact, so I changed the
primary key field in the new database to "number" instead of "autonumber" and
started using dmax in the forms to similate autonumber.

the problem is that if I use the formula in my previous post, the primary
key field doesn't get filled in and therefore no record is created. Causing
the "Not in list" to inform me that the value is not in the list even though
I thought I added it.

So, is there a way to force the number into the table for the primary key?
Or am I going about this all the wrong way?

I'm sure there is a way of adding dmax to the sql string, but I'm not sure
of the proper syntax for such a formula.

Thank you so much for any help.
 
Back
Top