Senin, 23 Mei 2011

[MS_AccessPros] Adding a record to a datasheet subform & filling in hidden fields

 

Hi,
I have a form with a bound datasheet subform. The table the subform is bound to has some data that needs to be hidden from the user, so when I created the subform I just left those fields out.

The problem I'm having is getting values to go into those hidden fields when someone adds a new row. For the non-hidden fields I just do dlookups based on the value entered IE:
Me.txtFullName = DLookup("FullName", "Employees", "EmplID = " & Me.txtEmplID & "")
etc. and it works fine.

For the hidden fields I tried to do an update query when the row is inserted, but I keep getting a "The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field." error. I read this is because it's trying to save things in 2 different places, but I've tried me.dirty = false in about 10 different places, and called the code from about 10 different events (form before update, after update, before insert, after insert, and control events for the same events), and I can't get rid of the error. At this point I think I'm over-complicating it.

I need these hidden values to be populated if someone tries to add a new row. If I put the text boxes hidden on the datasheet subform they still show up when it's not in design view. Is there any simple way I can do this?

Thanks
-Lee

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar