Command Button Causing Error

  • Thread starter Thread starter MN_Bill
  • Start date Start date
M

MN_Bill

I have a form, with a command button. The OnClick event
is set to execute some VBA code to use a field from the
form, search a recordset, if the field is found in the
recordset and open a second form (This is a different form
and a different recordset than the first form and its
recordset.) showing the record containing the located
record. Or, if the record is not found, add a new record
to the recordset and open the form pointing to the added
record.

The following thre lines are in the VBA code:

recordset.AddNew
recordset.field = value
recordset.Update

I get the error, "The expression On Click you entered as
the event property setting produced the following error:."

Can anyone shed any light on this?
Bill
 
Bill,

Not sure whether "recordset" is a reserved keyword, it probably is. This
would require you to use another name for your recordset.

What I am sure of, is your field reference "recordset.field" doesn't look
right; it should be either recordset.fields(index) where index is an integer
0,1,2... indicating the field position in the recordset, or
recordset.fields("FieldName") i.e. absolute reference by field name. Try
correcting this first, and if it doesn't solve the problem, then change the
recordset name to a non-reserved one.

HTH,
Nikos
 
Back
Top