Error Trapping Question

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

I have an Access FE tied to a SQL back end. If I have a required field set
in SQL server and try to leave it blank, you get an error message:

"You tried to assign the null value to a variable that is not a variant data
type"

I know how to trap for errors, but in this case it does not give me an error
number so I don't know what to check for.

how do I trap this SQL error and provide a more friendly user error message?

Thanks

Joe
 
Hi,

The error probably occurs in VBA/VB code. You should change your code to
either "Dim" the variable as a variant, either use Nz( ) around the field:

Dim x As Long
x=Nz( rst.Fields("fieldName").Value, 0 )


here, a possible NULL returned by the recordset will be changed to a zero.
You can use an empty string, vbNullString, if the field is eventually a
string.



Since the end-user is powerless to solve that problem, there is not a lot of
necessity to carry it to the end-user, in that case, if this *is* indeed the
case, it is a "bug" that requires the developer intervention.



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top