Update form on record change

L

luhui

Barry said:
Hi, i have a subform that needs to run the following code everytime the user
changes the record. The code is used to update textbox and labels on the form
so that the user only see's exactly what they need to see after they have
selected a source from the cboPartSource combo box. At the moment this is
working fine on the after update of the combo box but when the user changes
to a different record on the subform it does not update to show what is
already selected in the combo box. I have tried using the on current of the
form but it does not seem to work for me. Can anyone help me with this
problem or suggest a better way of doing this. Thanks in advance


Private Sub Form_Current()

If Me.cboPartSource.Value = "" Then
Me.lblSourceHeading.Visible = True
Me.lblSourceHeading.Caption = ""
Me.Box.Visible = True
Me.cboData1.Visible = False
Me.txtData1.Visible = False
Me.txtData2.Visible = False
Me.txtData3.Visible = False
Me.txtData4.Visible = False
Me.txtData5.Visible = False
Me.lblHeading1.Visible = False
Me.lblHeading2.Visible = False
Me.lblHeading3.Visible = False
Me.lblHeading4.Visible = False
Me.lblHeading5.Visible = False

ElseIf Me.cboPartSource.Value = "Original" Then
Me.lblSourceHeading.Visible = True
Me.lblSourceHeading.Caption = "Original"
Me.Box.Visible = True
Me.cboData1.Visible = False
Me.txtData1.Visible = True
Me.txtData1.ControlSource = "lngOrderDate"
Me.txtData1.InputMask = "00\-00;0"
Me.txtData2.Visible = True
Me.txtData2.ControlSource = "lngEstDeliveryWeek"
Me.txtData2.InputMask = "00\-00;0"
Me.txtData3.Visible = True
Me.txtData3.ControlSource = "chrOrderCon"
Me.txtData4.Visible = True
Me.txtData4.ControlSource = "lngOrderNo"
Me.txtData5.Visible = True
Me.txtData5.ControlSource = "lngActDeliveryWeek"
Me.txtData5.InputMask = "00\-00;0"
Me.lblHeading1.Visible = True
Me.lblHeading1.Caption = "Order Date"
Me.lblHeading2.Visible = True
Me.lblHeading2.Caption = "Estimated Delivery Date"
Me.lblHeading3.Visible = True
Me.lblHeading3.Caption = "Order Confirmation"
Me.lblHeading4.Visible = True
Me.lblHeading4.Caption = "Order No"
Me.lblHeading5.Visible = True
Me.lblHeading5.Caption = "Actual Delivery Date"
End If

End Sub
 
G

Guest

Hi, i have a subform that needs to run the following code everytime the user
changes the record. The code is used to update textbox and labels on the form
so that the user only see's exactly what they need to see after they have
selected a source from the cboPartSource combo box. At the moment this is
working fine on the after update of the combo box but when the user changes
to a different record on the subform it does not update to show what is
already selected in the combo box. I have tried using the on current of the
form but it does not seem to work for me. Can anyone help me with this
problem or suggest a better way of doing this. Thanks in advance


Private Sub Form_Current()

If Me.cboPartSource.Value = "" Then
Me.lblSourceHeading.Visible = True
Me.lblSourceHeading.Caption = ""
Me.Box.Visible = True
Me.cboData1.Visible = False
Me.txtData1.Visible = False
Me.txtData2.Visible = False
Me.txtData3.Visible = False
Me.txtData4.Visible = False
Me.txtData5.Visible = False
Me.lblHeading1.Visible = False
Me.lblHeading2.Visible = False
Me.lblHeading3.Visible = False
Me.lblHeading4.Visible = False
Me.lblHeading5.Visible = False

ElseIf Me.cboPartSource.Value = "Original" Then
Me.lblSourceHeading.Visible = True
Me.lblSourceHeading.Caption = "Original"
Me.Box.Visible = True
Me.cboData1.Visible = False
Me.txtData1.Visible = True
Me.txtData1.ControlSource = "lngOrderDate"
Me.txtData1.InputMask = "00\-00;0"
Me.txtData2.Visible = True
Me.txtData2.ControlSource = "lngEstDeliveryWeek"
Me.txtData2.InputMask = "00\-00;0"
Me.txtData3.Visible = True
Me.txtData3.ControlSource = "chrOrderCon"
Me.txtData4.Visible = True
Me.txtData4.ControlSource = "lngOrderNo"
Me.txtData5.Visible = True
Me.txtData5.ControlSource = "lngActDeliveryWeek"
Me.txtData5.InputMask = "00\-00;0"
Me.lblHeading1.Visible = True
Me.lblHeading1.Caption = "Order Date"
Me.lblHeading2.Visible = True
Me.lblHeading2.Caption = "Estimated Delivery Date"
Me.lblHeading3.Visible = True
Me.lblHeading3.Caption = "Order Confirmation"
Me.lblHeading4.Visible = True
Me.lblHeading4.Caption = "Order No"
Me.lblHeading5.Visible = True
Me.lblHeading5.Caption = "Actual Delivery Date"
End If

End Sub
 

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