Subform Combobox (1 Viewer)

Jonny45wakey

New member
Local time
Today, 02:37
Joined
May 4, 2020
Messages
14
Wondering if anyone has the wisdom to solve this for me please?

I have a form called "frmTransactMovement" which has a textbox called "status", on the form is a subform which contains a Combobox called

"id_State" with a dropdown selection of "Approved"

What i would like to happen is when the subform combobox is changed to "Approved" the textbox called "Status" in the main form has its field value changed to "Yes" or "Approved"

Cant seem to get this to work, any pointers / help appreciated.

Thanks

Jonny
 

arnelgp

error reading drive A:
Local time
Today, 09:37
Joined
May 7, 2009
Messages
12,011
add code to the combo_AfterUpdate event:

private sub combo_afterupdate()
me.parent!txtStatus = iif(me!combo = "Approved", "Yes", "No")
end sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:37
Joined
Feb 19, 2002
Messages
31,482
Storing the same data multiple times is always problematic and that is why it violates third normal form. In this case, there is also a logic error. Presumably you have multiple rows related to the one in the main form. Since the mainform cannot store values from ALL subform records, it doesn't make sense for any single subform record to modify a value in the main form record.

There is some logic to having the mainform changed if ALL subform values are "approved". To do this, use the AfterUpdate event of the subform. Run two dCounts. One to count all the subform rows and the second to count all the approved rows. If the two counts are the same, change the mainform status to Approved.

Mind you, I am NOT saying that this is recommended because it still violates third normal form, only that it is at least logical.

Do some reading on normal forms. The Wikipedia entries are less obtuse than many others. If your eyes cross when you read a description of one of the first three normal forms, go to a different reference. Unless you already understand relational algebra, the "scholarly" entries won't make any sense at all.
 

Users who are viewing this thread

Top Bottom