Not forcing values to be equal

B

Barry

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
 
J

John W. Vinson

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]
 
B

Barry

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?

John W. Vinson said:
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]
 
J

John W. Vinson

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?

John W. Vinson said:
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]
 
B

Barry

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?

John W. Vinson said:
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]
 
B

Barry

And yes, you are right, John...the subform control is connected to the combo
box on the mainform through Parent/child relationship in the form's
properties. And yes, the "On Click" property for the subform control is what
triggers the VBA event. Sorry, I am not familiar with VB enough to try
changing the script to what you have suggested.

Barry said:
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top