If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
update on record
I'm using the following with a click command and it works fine. How can I
make it work when I scroll through the records on my form? current, dirty, etc... What would be the proper way? Thanks. Dim sPartNo As String Dim sPDFName As String Const conDrawingFolder As String = "\\server\drawings\" sPartNo = Me![New2] & vbNullString If Len(sPartNo) = 0 Then Image379.Visible = False Else sPDFName = conDrawingFolder & sPartNo & ".pdf" If Len(Dir(sPDFName)) = 0 Then Image379.Visible = False Else Image379.Visible = True End If End Sub |
#2
|
|||
|
|||
update on record
"rml" wrote in message
... I'm using the following with a click command and it works fine. How can I make it work when I scroll through the records on my form? current, dirty, etc... What would be the proper way? Thanks. Dim sPartNo As String Dim sPDFName As String Const conDrawingFolder As String = "\\server\drawings\" sPartNo = Me![New2] & vbNullString If Len(sPartNo) = 0 Then Image379.Visible = False Else sPDFName = conDrawingFolder & sPartNo & ".pdf" If Len(Dir(sPDFName)) = 0 Then Image379.Visible = False Else Image379.Visible = True End If End Sub If I understand you properly, you would just put that code (minus the End Sub line you quoted) in the Current event of your form: Private Sub Form_Current() ' ... your code here ... End Sub Note, though, that this method can't be used on a continuous form to show/hide the Image379 control differently for each of the multiple records displayed. That's because, even on a continuous form, only one record is current at a time. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#3
|
|||
|
|||
update on record
I think I know what is going on. On my form, I have some code that displays
a graphic on current. So, in the on current I have =SetImagePath() so I think that why the other code is not firing. How can I make them both co-exist? With the =SetImagePath() I can't go to the code builder? It goes straight into expression builder. Does all that make sense? Thanks. "Dirk Goldgar" wrote: "rml" wrote in message ... I'm using the following with a click command and it works fine. How can I make it work when I scroll through the records on my form? current, dirty, etc... What would be the proper way? Thanks. Dim sPartNo As String Dim sPDFName As String Const conDrawingFolder As String = "\\server\drawings\" sPartNo = Me![New2] & vbNullString If Len(sPartNo) = 0 Then Image379.Visible = False Else sPDFName = conDrawingFolder & sPartNo & ".pdf" If Len(Dir(sPDFName)) = 0 Then Image379.Visible = False Else Image379.Visible = True End If End Sub If I understand you properly, you would just put that code (minus the End Sub line you quoted) in the Current event of your form: Private Sub Form_Current() ' ... your code here ... End Sub Note, though, that this method can't be used on a continuous form to show/hide the Image379 control differently for each of the multiple records displayed. That's because, even on a continuous form, only one record is current at a time. -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#4
|
|||
|
|||
update on record
"rml" wrote in message
... I think I know what is going on. On my form, I have some code that displays a graphic on current. So, in the on current I have =SetImagePath() so I think that why the other code is not firing. How can I make them both co-exist? With the =SetImagePath() I can't go to the code builder? It goes straight into expression builder. Does all that make sense? Yep. In order for your Current event procedure to be called, the form's OnCurrent property must be set to "[Event Procedure]". If you want to both execute your procedure code and call the SetImagePath() function, you can call SetImagePath() from your event procedure. Change the OnCurrent property to "[Event Procedure]" (without the quotes), and build an event procedure along these lines: '----- start of example code ----- Private Sub Form_Current() Dim sPartNo As String Dim sPDFName As String Const conDrawingFolder As String = "\\server\drawings\" On Error GoTo Err_Handler SetImagePath ' Display or hide Image control, depending on whether ' the PDF is found. sPartNo = Me![New2] & vbNullString If Len(sPartNo) = 0 Then Image379.Visible = False Else sPDFName = conDrawingFolder & sPartNo & ".pdf" Image379.Visible = (Len(Dir(sPDFName)) 0) End If Exit_Point: Exit Sub Err_Handler: ' For now, if there's an error -- maybe bad path to server -- ' just hide the image control. More comprehensive error ' checking and response should probably be added. Image379.Visible = False Resume Exit_Point End Sub '----- end of example code ----- -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
#5
|
|||
|
|||
update on record
That worked perfect! Thanks.
"Dirk Goldgar" wrote: "rml" wrote in message ... I think I know what is going on. On my form, I have some code that displays a graphic on current. So, in the on current I have =SetImagePath() so I think that why the other code is not firing. How can I make them both co-exist? With the =SetImagePath() I can't go to the code builder? It goes straight into expression builder. Does all that make sense? Yep. In order for your Current event procedure to be called, the form's OnCurrent property must be set to "[Event Procedure]". If you want to both execute your procedure code and call the SetImagePath() function, you can call SetImagePath() from your event procedure. Change the OnCurrent property to "[Event Procedure]" (without the quotes), and build an event procedure along these lines: '----- start of example code ----- Private Sub Form_Current() Dim sPartNo As String Dim sPDFName As String Const conDrawingFolder As String = "\\server\drawings\" On Error GoTo Err_Handler SetImagePath ' Display or hide Image control, depending on whether ' the PDF is found. sPartNo = Me![New2] & vbNullString If Len(sPartNo) = 0 Then Image379.Visible = False Else sPDFName = conDrawingFolder & sPartNo & ".pdf" Image379.Visible = (Len(Dir(sPDFName)) 0) End If Exit_Point: Exit Sub Err_Handler: ' For now, if there's an error -- maybe bad path to server -- ' just hide the image control. More comprehensive error ' checking and response should probably be added. Image379.Visible = False Resume Exit_Point End Sub '----- end of example code ----- -- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup) |
Thread Tools | |
Display Modes | |
|
|