A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

update on record



 
 
Thread Tools Display Modes
  #1  
Old April 2nd, 2008, 05:39 PM posted to microsoft.public.access.forms
rml
external usenet poster
 
Posts: 172
Default 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  
Old April 2nd, 2008, 06:34 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default 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  
Old April 2nd, 2008, 07:20 PM posted to microsoft.public.access.forms
rml
external usenet poster
 
Posts: 172
Default 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  
Old April 2nd, 2008, 07:41 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default 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  
Old April 8th, 2008, 02:58 PM posted to microsoft.public.access.forms
rml
external usenet poster
 
Posts: 172
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:48 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.