Error if nothing selected in Combobox

sbuckingham25

Registered User.
Local time
Today, 03:45
Joined
Jun 12, 2008
Messages
27
I have a combo box in a form. If nothing is selected, I get this error:

The Micro Jet databse engine cannot find a record int the table "TblParts'with key matching field(s) 'Parts'.

Is there a way to have the field null, there will be jobs that Parts won't need to be selected.
 
I believe you get this error because you have a relationship between the two fields, so basically what you've told it to do is when you add a job then there will NEED to be a part selected. So i think if you fix the relationship up, you should be good. I think this is right, I'm still kind of new to Access so i might be wrong.
 
error handling

so it works if the combo's have a value? are you handling errors? if not, just catch the error and do something with it. to do that try:
Code:
Public Sub SomeSubOrFunction
On Error GoTo errorhandler
 
'your code....
 
errorhandler:
If Err.Number = 0 Then
elseif err.number =  25 then  'change this number to your errornumber
msgbox("Im sorry, you must make a selection")
Else
MsgBox (Err.Description)
' if you dont know the error number to cach, 
'change description to number and see what pops

End If
End Sub
 
change the default value of the field part in your table from 0 to null
no need to ammend any relationships

Khawar
 

Users who are viewing this thread

Back
Top Bottom