Full Version: Detail Section Of A Continuous Form Not Updating Each Line
UtterAccess Forums > Microsoft® Access > Access Forms
whitechair
I have a subform in a tabcontrol in a main form. I have this code written in the OnLoad event of a "Continuous Forms" subform:
Private Sub Detail_Paint()
Dim strURL, TrkNo As String
TrkNo = Nz(Me.txtTrackingNo, "")
If Me.Text20 = "UPS" Then
strURL = "http://wwwapps.ups.com/etracking/tracking.cgi?tracknums_displayed=5&TypeOfInquiryNumber=T&HTMLVersion=4.0&InquiryNumber1=" & TrkNo & "&InquiryNumber2=&InquiryNumber3=&InquiryNumber4=&InquiryNumber5=&track.x=0&track.y=0"
Me!lblTrackingNo.HyperlinkAddress = strURL
Me!lblTrackingNo.ForeColor = 16711680
Me!lblTrackingNo.FontUnderline = True
Me!lblTrackingNo.Caption = TrkNo
ElseIf Me.Text20 = "FedEx" Then
strURL = "http://www.fedex.com/Tracking?clienttype=dotcom&ascend_header=1&cntry_code=us&language=english&mi=n&tracknumbers=" & TrkNo
Me!lblTrackingNo.HyperlinkAddress = strURL
Me!lblTrackingNo.ForeColor = 16711680
Me!lblTrackingNo.FontUnderline = True
Me!lblTrackingNo.Caption = TrkNo
Else
TrkNo = ""
strURL = ""
Me!lblTrackingNo.HyperlinkAddress = strURL
Me!lblTrackingNo.ForeColor = 16711680
Me!lblTrackingNo.FontUnderline = False
Me!lblTrackingNo.Caption = TrkNo
End If
End Sub
It does what I want it to, except that it doesn't change with each record. txtTrackingNo has a different tracking number on each record, but the label I am updating shows the same tracking number and URL on each record in the subform. What am I doing wrong.
jleach
Hi,
The Form_Load event runs once, as the form is initialized (be it a subform or mainform). The Form_Current() event is raised each time the record is changed, but beware: it's often highly overused and runs very often.
hth
whitechair
I tried the Form Current event and it didn't help at all. In fact it caused it to set both the TrackNo and the URL to the same number on each record. The record it sets it to is always the first one. It's like it is running the code on the first record and then setting every record after that equal to that calculation. How can I get it to run the code for each record?
vtd
I don't quite understand your original description???
You wrote that you use the Form_Load Event but the declaration for the code was
Private Sub Detail_Paint()
???
OTOH, your code won't work with a (Sub)Form in ContinuousFormView, regardless of the Event used, since what you see is the many instances of the same Control all all instances will look the same, i.e. same ForeColor, FontUnderline, Caption.
Probably the only work-around if you want to use the ContinuousFormView is to use the TextBox Control in lieu of the Label Control and use the Conditional Formatting on the TextBox.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.