Starting from the beginning, below is a copy of the VB code that was exported
from the macro. When run, as an event procedure On Click event, it does not
update the value, even though it did in the macro (but returned errors).
Function Forms_UpdateWellIDPar()
On Error GoTo Forms_UpdateWellIDPar_Err
' Updates new Well Location record in frmWell_Parameters based on what
is visible in Combo box 34
Forms!frmWellMaintenance!tblWell_Parameters.Form!WELL_ID =
Forms!frmWellMaintenance!Combo34
Forms_UpdateWellIDPar_Exit:
Exit Function
Forms_UpdateWellIDPar_Err:
MsgBox Error$
Resume Forms_UpdateWellIDPar_Exit
End Function
John W. Vinson said:
It should do so, for the currently selected record on the subform
frmWellMaintenanceSub (if there is such a record). I take it that this code is
connected to the mainform? What event (if any) triggers it - there is no
UpdateWellID event? Do you know that the code is in fact being run? Should
this perhaps be in
Private Sub WellID_AfterUpdate()
instead?
Sorry, yes this is a question.
How come the script does not force the 'Well Location' field to be equal to
the value in 'Combo34' combo box, based on the line setting them equal?
:
Function Forms_UpdateWellID()
On Error GoTo 0
DoCmd.Echo False, ""
DoCmd.SetWarnings False
' Updates new Well Location record in frmWellMaintenanceSub based on
what is visible in Combo box 34
Forms!frmWellMaintenance!frmWellMaintenanceSub.Form![Well Location] =
Forms!frmWellMaintenance!Combo34
Forms_UpdateWellID_Exit:
Exit Function
Do you have a question, Barry? What are you trying to accomplish? What's
happening or not happening?--
John W. Vinson [MVP]