Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem updating field in suborm

Status
Not open for further replies.

lizray

Programmer
May 14, 2008
126
AU
I have a form containing a subform which displays as a datasheet.The recordsource for the subform is a SQL statement. I open a second form in form view with fields displayed in textboxes, using the same recordsource as the datasheet. On certain conditions I want to set a field to Null by programatically setting the texbox to NULL. I use the Beforeupdate event for the second form but get the message "run time error Update or Cancelupdate without addnew or edit". I thought I was not dealing with the recordset directly, but through the textbox and its recordsource and that would allow me to simply change the value for that field...any ideas ?
 
The subform (displays as datasheet)on the main form has a recordset defined by an SQL statement and this works well. The “Form-view” , opens “hidden” and uses the same recordset. i.e.

Set Forms![form-view].Recordset = Forms![main].mainsubform.Form.Recordset

The Double-click event of a control on the subform then makes the “form-view” visible. The Datasheet form is still open, but is not seen as the "form-view" overlays it

The before update event of the “form-view” checks if a field = a predetermined value and if so will try to make it NULL. i.e.

If [Place] = strPlace Then Place = NULL

It is this attempt to write a NULL that causes the error message

I notice that the beforeupdate event seems to occur on the “form-view” even if there is no change to a control on the “form-view”
 
Solved..sorry for problem. It seems that my database had become contaminated, when I started with a new copy evrything worked
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top