Web Development



Referencing result of running a Select query in Access VBA code

By Mitchlyn_Gentry ·
I'm teaching myself Access VBA and I'm stumped. I want to execute code depending on if a record has already been entered in a table. Basically, if the record already exists, I want to update it. If it doesn't exist, I want to add it.

To accomplish this, I chose to execute a Select query where the record key equals what I'm looking for. If the query returns a NULL recordset, I know what to do.

How do I capture the ERR.Description that comes back when I get the NULL recordset on a "DoCmd.RunSQL XXXXX" command?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

I'm no expert

by alec.wood In reply to Referencing result of run ...

As above, new to database and teaching myself VBA same as you, but here's my best shot

DIM intErrorNum as Integer
ON ERROR GOTO errortrapthingy

intErrorNum = ERR.Number
IF intErrorNum= <required error number> THEN
do stuff
MsgBox ERR.Description

Related Discussions

Related Forums