Calculate a table field value from unbound textbox

Skip Bisconer

Who Me?
Local time
Today, 15:22
Joined
Jan 22, 2008
Messages
285
I would like to place a value in an unbound textbox and have a bound field retain the unbound value after update, Have tried using the bound fields default value and using code in the afterupdate event but I can't make it work. I am trying to do a work around from a previously unrequited post. The following is the code I used for the Afterupdate. Any help is appreciated.

Private Sub RouteID_AfterUpdate()
Me.RouteID.Value = Me.PegRoute.Value

End Sub
 
yuo probably hasve this back to front

Private Sub RouteID_AfterUpdate()
Me.RouteID.Value = Me.PegRoute.Value

what you ARE saying, is AFTER you have updated routeid, NOW set it to a different value (ie pegroute)

this cant be what you meant
 
The RouteID is the bound field. PegRoute is the unboud field. I need RouteID to always be the value of PegRoute. When I want RouteID to change to a different value I put a different value in PegRoute. I hope I am clear here. Thanks for responding.
 
then in PEGROUTE afterupdate put

Private Sub pegroute_AfterUpdate()
RouteID = PegRoute

-------
dont use the me's and .values's excessively - sometimes they actually cause errors i think - you generally dont need them anyway
 
New problem has arisen. I don't want the RouteID to change value if it already has a value so I am trying this code but I get a "424 Object Required" halt. At first I didn't have the Me. in front of the field name but after putting in the Me. I still get the error. To make your previous help work in the afterupdate I had to change it to a unbound lookup combobox instead of the PegRoute as that was the source of the update and that made it all work there.
If Me.RouteID Is Null Then
Me.RouteID = Me.PegRoute
Else
Me.RouteID = Me.RouteID
End If
 
you are better to use nz, rather than just is null

for numeric values

If nz(Me.RouteID,0)=0 Then
Me.RouteID = Me.PegRoute
end if

for text values
If nz(Me.RouteID,vbnullstring)=vbnullstring Then
Me.RouteID = Me.PegRoute
end if


nz with text valuies is ESPECIALLY useful, as it is very hard to distinguish between null and "" (a zero length string)

{you dont need this if its not changing!}
Else
Me.RouteID = Me.RouteID
End If
 
I have gotten this error before but I don't know what's causing it. Error 2001 "you canceled previous operation" occured when I tried to selected an unassigned order from the unbound combobox in SplitForm view. This is the code assigned to the combobox afterupdate.
Private Sub Combo8_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OEOO_ORDR] = " & Str(Nz(Me![Combo8], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

If Nz(Me.RouteID, vbNullString) = vbNullString Then
Me.RouteID = Me.PegRoute
End If

DeliverySeq.SetFocus
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom