Not in list issue

rexb

Registered User.
Local time
Yesterday, 21:04
Joined
Oct 29, 2008
Messages
129
I've got this code from other source for the "Not in list" for combo box

code:
Dim ctl As Control
Dim strSQL As String
Set ctl = Me!AssetType
If MsgBox("Value is not in list. Add it?", _
vbOKCancel) = vbOK Then
Response = acDataErrAdded

strSQL = "INSERT INTO tbleAssettype(list) VALUES('"
strSQL = strSQL & NewData & "');"
CurrentDb.Execute strSQL
Else
Response = acDataErrContinue
ctl.Undo
End If

-

I get error message "runtime error 3192"

My table has to fields
1. assetid - primary but not autonumber just number
2. assetdesc
 
My table has to fields
1. assetid - primary but not autonumber just number
2. assetdesc
Why not use an autonumber for your primary key? You really need not be concerned with the "behind the scenes" workings of the system stuff. Let Access manage those and just use them. You could still have your own AssetID if you needed but leave the primary keys to Access. I've seen too many problems with setups where people think they need to manage the primary keys.

Anyway, the problem is that you can't insert like you want because you aren't providing a primary key to the table as well as the new data. So, because you are managing them (instead of letting Access do it with an autonumber) you need to include that field and pass the new key in as well.
 
thank you very much
 

Users who are viewing this thread

Back
Top Bottom