transfering data from the sub form into the form in ACCESS run-time 2007

HilaDG

New member
Local time
Tomorrow, 05:11
Joined
Nov 25, 2008
Messages
7
Hi all,
I had this problem and I thought I might share the solution with you:
I use access 2003 in development and distribute with Access 2007 run-time.

I have a form with a combo-box, two buttons ('delete' and 'close') and a sub-form, that the information inside it is linked to the combo-box.
The table that the form is linked to contains a field for 'soft deletion' called 'ac_deleted'. Obviously I would like to enavle the cmd_delete control if and only if the ac_deleted field is marked.

In access 2003 this line would work perfectly:
Me!cmd_delete.Enabled = Me!sub_ac.Form!ac_deleted

But in run-time 2007 it would give me a 'type mismatch' error whenever I changed the data in the combo box (=changed the data that the sub form is linked to).
So I changed the line into this:
Me!cmd_delete.Enabled = IIf(Nz(Me!sub_ac.Form!ac_deleted, 0) <> 0, True, False)

But in run-time environment it 'sometimes worked'. i.e. sometimes it would display the data properly (or in my case, disable the control) and sometimes it wouldn't.
My work around for this problem was simply to use the 'DLookUp' function (this table contain less then 1000 lines) like this:

Me!cmd_delete.Enabled = IIf((DLookup("ac_deleted", "dbo_account", "ac_id =" & Me!cmb_account) <> 0), True, False)

(please note the the 'ac_deleted' field cannot be NULL)
And that gave me (finally) the consistent results which I was looking for.
I thought I'd post this in case anyone else has this problem.
 

Users who are viewing this thread

Back
Top Bottom