Skip to contents

Looks up a record in a database table and returns the ID of the record. If the record is not found it is inserted to the table and the ID of the new record is returned.

Usage

hsLookupOrAddRecord(
  mdb,
  tbl,
  keyAssigns,
  fieldAssigns = NULL,
  idField = hsFields(mdb, tbl)[1],
  dbg = FALSE
)

Arguments

mdb

full path to MS Access database

tbl

name of table in which record is to be looked up

keyAssigns

key-value-assignements used to identify the record to be looked up. The assignments are defined in forms of a list, e.g. list(key1 = "value1", key2 = "value2").

fieldAssigns

further field-value-assignements used when a new record needs to be inserted. The assignments are defined in forms of a list, e.g. list(field1 = "value1", field2 = "value2").

idField

name of ID field, default: name of first table field

dbg

if TRUE, debug messages are shown