Question

Locked

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.

1 total post (Page 1 of 1)  
| 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

errortrapthingy:
intErrorNum = ERR.Number
IF intErrorNum= <required error number> THEN
do stuff
ELSE
MsgBox ERR.Description
EXIT SUB
END IF

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums