Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update an unbound field

Status
Not open for further replies.

gys67

Programmer
Nov 4, 2003
19
US
Hi,

I have a form where I'm trying to update a field (field2) using the data from another field (field1). Both the data fields have been created as unbound data fields in the form. What I would like to do is, use the 1st character from field1, which is a drop down box and update field2 with it. The code I have in place displays the first character of field1 in field2 successfully, but doesn't write the update to the table.
Please help....

Thanks very much!!!

 
By default unbound fields will not write values to your table.

If you wish to have the value written to a table you will need to have a bound field that can capture what the data is.


HTH,

Steve
 
Thanks for your response Steve...

Actually, I do have various other unbound fields in my form and those fields get updated perfectly when I make a manual change. because I do bind them in a module

e.g. DHM_ID_TYPE.ControlSource = "DHM_ID_TYPE"

Even the field2 I was talking about has been bound in that module. If I enter the value manually in the field, it does get updated. Its just that when I use the combo boc to choose a value, the desired valus is dsiplayed in field2 but not written...

Here is the code I use to get the value...

Private Sub field1_AfterUpdate()
Dim strcot As String
strcot = field1.Text
strcot = Left(strcot, 1)
field2.SetFocus
field2 = strcot
end sub

should I write a specific update statement after this...
Even if I write one, how do I execute it???

Thanks...


 
The afterupdate event only fires when the data in the control is manipulated by the keyboard or mouse, not if you update the data in that control through code.

Best is to break out the above code into a sub or function and call it both in the control's afterupdate and in the code that's changing the value of that control.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top