View Full Version : assigning a value to a field on load


helenpostle
02-06-2002, 03:39 AM
I've got a field called sampleNo and one called newSampleNo. newSampleNo runs a query to find the largest sampleNo in the table and adds 1 to it. If I set code for the double click event of this field to Me!sampleNo = Me!newSampleNo.Value, when I double click the field, sampleNo is updated. However, I would like to set the same code in the form onLoad event but it keeps coming up with an error saying the field sampleNo can't contain a null value. I can't understand why the code works for a double click event but not for an onload event? Can anyone help please

Helen

mkleino
02-06-2002, 05:23 AM
I don't understand...is the form based on a query that includes both sampleno and newsampleno? And why do you want to use the OnLoad property? Are you trying to update only the first record?

In any case, OnLoad occurs before any data is loaded into the form. If you want to update the field for every record, use OnCurrent, which will run every time you change records, including when you open the form. However, if that's what you want I don't know why you can't just make newsampleno a control on the form.

Hope that helps a bit; if you could clarify things maybe I could be more specific.

-Mike