Hello,
I have a form that Inserts a record onto a table.
I would like to add code to do the following:
- first check to see if the record exists
- if it does exist, update it
- if it doesn't exist, insert it.
This table is not the record source of my form.
I tried coding sql in vba to do the SELECT, and after many rounds of it not working, I read on tek-tips that sql in this way only works for an action query, not a select query. Am not sure how else to do this logic. Set this sql up in a query? (then how do I reference the record count? and how would i do the update?). Or, should I use something like currentdb.execute? Would I have 3 separate statements? (find, then insert or update?)
I know I need to retrieve the record, check the record count, and if it's 0, add the record; if it's >0, update the record. Just not sure about the details on how to do so.
Appreciate any help!
many thanks in advance
I have a form that Inserts a record onto a table.
I would like to add code to do the following:
- first check to see if the record exists
- if it does exist, update it
- if it doesn't exist, insert it.
This table is not the record source of my form.
I tried coding sql in vba to do the SELECT, and after many rounds of it not working, I read on tek-tips that sql in this way only works for an action query, not a select query. Am not sure how else to do this logic. Set this sql up in a query? (then how do I reference the record count? and how would i do the update?). Or, should I use something like currentdb.execute? Would I have 3 separate statements? (find, then insert or update?)
I know I need to retrieve the record, check the record count, and if it's 0, add the record; if it's >0, update the record. Just not sure about the details on how to do so.
Appreciate any help!
many thanks in advance