I have a form that I would like to set a field value on based on the input from another field value. I would like to look up a value in a table based on a value already inputted in the form and have that lookup value automatically show in another form field.
hi,
are you in dialog box and you are speking of edit control?
Suppose yes; you have a control call it MASTER and another
call it SLAVE.
Define for them CString Member Variable, call them cMaster and cSlave
In the Master you have to check the value: you can do it when you leave it (by tab or mouse) or while the value is changing: in 1st case define in message map, the event
EN_KILLFOCUS, in te 2nd EN_CHANGE. In the routine you define
associated with this event, call the UpdateData( TRUE ):
this will update the variable cMaster.
Always in this routine, do your consideration, build the
cSlave variable and call the UpdateData( FALSE ):
this will update all controls and then also SLAVE.
If you don't wont define Member variables, use system call
SetWindowText and GetWindowText together with GetDlgItem.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.