Results 1 to 14 of 14
  1. #1
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10

    DWF in a Report

    I've created a database for some gaskets here at work. I've got everything working that I need, but I can't seem to get the imagery right.

    My problem starts here:
    I have a Secondary Form that sorts the gaskets out of the Main Form by "TYPE ". The form consists of a ComboBox that has a pull down "TYPE" from a Table linked to the Main Table. The form also has a print preview button that shows a subform with all of the info from the main table of each record of that specific "TYPE" and a Print Button that prints those sorted records. They're all properly linked to appropriate Queries and Reports. I added another button to print .pdf images of each sorted record, and it worked with a simple query and the link to the phycial PDF location in another column under the Main Table, but the images print out really pixelated/grainy (good quality pdf's btw, from autocad), so I batch printed out some good .dwf files for each record to try that approach.

    I removed the image box from my Main Form and replaced it with an ActiveX Autodesk DWF Viewer Control box. On my Main Form, where you view each Record individually, the .dwf turns out great. I wrote VBA to have it find the actual .dwf file in it's location, then linked it to all the buttons, etc on the Form. An almost identical code is not returning [PN] results on the Report:

    Option Compare Database
    Private Sub FindDWF2()
    Dim Viewer As IAdPageViewer
    Set Viewer = CEView2.Viewer
    On Error GoTo NoPic


    strpic2 = Me![PN]
    strpic2 = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf"
    If strpic2 = "M:\Part Database\gasketdwgs\-Model.dwf" Then
    strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    End If
    drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2


    Exit Sub


    NoPic:
    strpic2 = NoPic
    drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2


    End Sub


    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    On Error GoTo NoPic
    Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf"
    Exit Sub


    NoPic:
    Me.CEView2.SourcePath = NoPic
    End Sub
    (note, all of the gaskets are found by Part Number [PN] and have the tag "- Model" written after every part # on the physical .dwf path)

    The result right now is "Path does not exist, Please verify the correct path was given. M:\Part Database\gasketdwgs\-Model.dwf", then gives me the appropriate number of blank white pages. Apparently, the FindDWF2 isn't finding the part number based on the query.

    What I'm trying to do is do the same thing with the PDF files, but with DWFs. They don't seem to embed like the PDF's, but I think they'd turn out grainy too if I could. So, I put an ActiveX Autodesk DWF Viewer Control box in the appropriate report, got the Query lined up right and when I run the report, it gives me the appropriate number of ActiveX Autodesk DWF Viewer Control boxes, but only a gray box with the globe and colored arrows shows up (typical activex default image). I'm thinking I need VBA for the report similar to what I wrote for the main table, but I don't know how to link it to all appropriate sources.

    Ideally, when i'm in the TYPE Sorting Form, I want to print the sorted .dwf records with a press of the button like I have with the text records. If there's an easier way than the way I'm going, I'm open for suggestions?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Don't know if any of this will help, but:

    You should have "Option Explicit" as the second line on every code page. This is an option that can be set. In A2K, in the IDE, goto "TOOLS" / "Options" / "Editor" tab. Check the checkbox "Require Variable Declaration"

    "strpic2" has not been declared in either subroutine

    What is "NoPic"? It has not been declared, but it is a label.
    Do you have a control named "PN"?

    In the code you have "-Model.dwf" (without a space), but you say ".... and have the tag "- Model" written after....' (with a space). Which is correct? (this is one reason why I don't use spaces)

    Have you single stepped through the code, checking the local variables to see if the correct data is there?



    Code:
    Option Compare Database  ' Use database order for string comparisons.
    Option Explicit  ' Requires variables to be declared before they are used.
    
    Private Sub FindDWF2()
       On Error GoTo NoPic
       
       Const ThePath As String = "M:\Part Database\gasketdwgs\"
       Const TheExt As String = "-Model.dwf"
       
       Dim Viewer As IAdPageViewer
       
       Set Viewer = CEView2.Viewer
    
       strpic2 = Me![PN]
       strpic2 = ThePath & strpic2 & TheExt
       If strpic2 = ThePath & TheExt Then
          strpic2 = ThePath & "DWFTemplate" & TheExt
       End If
       
       Me.drawpath.Caption = strpic2
       Me.CEView2.SourcePath = strpic2
    
       Exit Sub
    
    NoPic:
       strpic2 = NoPic     '<<<----- what is NoPic????
       Me.drawpath.Caption = strpic2
       Me.CEView2.SourcePath = strpic2
    End Sub
    
    
    
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
       On Error GoTo NoPic
       
       Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf"
       Exit Sub
    
    NoPic:
       Me.CEView2.SourcePath = NoPic     '<<<----- what is NoPic????
    End Sub

  3. #3
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Quote Originally Posted by ssanfu View Post
    "strpic2" has not been declared in either subroutine"
    how do i do that? I'm really learning as I go here... only been a few weeks.

    Quote Originally Posted by ssanfu View Post
    What is "NoPic"?
    I don't know. I copied the code from another access file my boss wrote. What should I do with it?

    Quote Originally Posted by ssanfu View Post
    Do you have a control named "PN"
    It's one of the fields in the Main Records Table

    Quote Originally Posted by ssanfu View Post
    In the code you have "-Model.dwf" (without a space), but you say ".... and have the tag "- Model" written after....' (with a space). Which is correct? (this is one reason why I don't use spaces)
    Shouldn't have spaces.

    Quote Originally Posted by ssanfu View Post
    Have you single stepped through the code, checking the local variables to see if the correct data is there?
    Been trying along the way to keep consistency.

  4. #4
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    The path to the DWF files should be:
    M:\Part Database\gasketdwgs\PN(part number)-Model.dwf

    the part number should be filtered by the query (type from combobox) so it doesn't find EVERY part number

  5. #5
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Ok, so now I have this as my code:

    Option Compare Database
    Option Explicit


    Private Sub FindDWF2()
    On Error GoTo NoPic

    Const ThePath As String = "M:\Part Database\gasketdwgs\"
    Const TheExt As String = "-Model.dwf"
    Const strpic2 As String = Me![PN]

    Dim Viewer As IAdPageViewer

    Set Viewer = CEView2.Viewer


    strpic2 = Me![PN]
    strpic2 = ThePath & strpic2 & TheExt
    If strpic2 = ThePath & TheExt Then
    strpic2 = ThePath & "DWFTemplate" & TheExt
    End If

    Me.drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2


    Exit Sub


    NoPic:
    strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2


    End Sub


    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    On Error GoTo NoPic


    Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf" <----compile error : variable not defined (strpic2). how do I define that?
    FindDWF2
    Exit Sub
    NoPic:
    strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2
    End Sub

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf" <----compile error : variable not defined (strpic2). how do I define that?
    Dim strpic2 as string



    You might Google "database naming conventions"

    Here is one site:http://en.wikipedia.org/wiki/Leszyns...ing_convention
    Leszynski naming convention
    scroll down to: The LNC Tags for VBA Variables

    So the "str" prefix means it is a string.

  7. #7
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Hi All,

    Hope you all had a great weekend.

    After coming back and tweaking a few things, my code looks like this:

    Option Compare Database
    Option Explicit


    Private Sub FindDWF()
    On Error GoTo NoPic
    Dim Viewer As IAdPageViewer
    Dim strpic2 As String
    Set Viewer = CEView2.Viewer


    Const ThePath As String = "M:\Part Database\gasketdwgs\"
    Const strpic2 As String = Me![PN]
    Const TheExt As String = "-Model.dwf"


    strpic = Me![PN]
    strpic = ThePath & strpic2 & TheExt
    If strpic2 = NoPic Then
    strpic2 = ThePath & "DWFTemplate" & TheExt
    Exit Sub


    NoPic:
    strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    Me.drawpath.Caption = strpic2
    Me.CEView2.SourcePath = strpic2


    End Sub




    Private Sub Detail_Format()
    On Error GoTo NoPic


    Dim strpic2 As String


    Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf"
    FindDWF
    Exit Sub




    NoPic:
    strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    End Sub


    The result is the appropriate amount of forms displayed, but they are blank white pages. They should pull up the drawing "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf" or the actual dwf file, not just the white page. I assume my query is correct because it brings up the right amount of record pages, but somewhere the image gets lost in the report dwf viewer code. I'm wondering if I'm using the correct Viewer. I tried all of the IAdDWF types, but it only pulls up the view window for a split second. Maybe it's not that at all though...

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Detail_Format()
       On Error GoTo NoPic
    
       Dim strpic2 As String '  <<- this is declared, but never assigned a value!!!
    
       Me.CEView2.SourcePath = "M:\Part Database\gasketdwgs\" & strpic2 & "-Model.dwf" '<< strpic2 is NULL
       
       FindDWF  '<<- this is a call to the subroutine FindDWF. At this point, execution jumps to FindDWF
       Exit Sub '<<- upon return from the call to "FindDWF", execution resumes here. This really isn't needed because no code follows
    
    NoPic:
       strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf" '<< since "strpic2" is a variable declared in this sub, it goes away when the sub ends. It doesn't do anything
    End Sub


    Code:
    Private Sub FindDWF()
       On Error GoTo NoPic
       Dim Viewer As IAdPageViewer
       Dim strpic2 As String
       
       Set Viewer = CEView2.Viewer
    
       Const ThePath As String = "M:\Part Database\gasketdwgs\"
       Const strpic2 As String = Me![PN] ' << Duplicate declaration!!!
       Const TheExt As String = "-Model.dwf"
    
       strpic = Me![PN]  '<<< "strpic" is not declared!!
       strpic = ThePath & strpic2 & TheExt '<< why do this?
       
       If strpic2 = NoPic Then '<< NoPic is a label!! Part of the Error handler...    ?????
          strpic2 = ThePath & "DWFTemplate" & TheExt '<< what are you going to do with "strpic2"?? Next line exits the sub. Haven't done anything with "strpic2"
          Exit Sub
       End If
    
    NoPic:
       strpic2 = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf" '<< Whatever WAS in "strpic2" (from above code) is now replaced...
       Me.drawpath.Caption = strpic2
       Me.CEView2.SourcePath = strpic2
    
    End Sub
    I apologize, I am not trying to pick apart your code. These are the things I see that need correcting.

  9. #9
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    I'm glad you are, obviously I don't know how to write code yet. I'll try to resolve these issues and get back. thank you very much.

  10. #10
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    so here's the deal:

    my report isn't finding any of the [PN]s from the form because it's reading a subform, which in design view looks like a blank white sheet... eg, no physical table properties.

  11. #11
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Another day, another try. So in talking with my boss, he mentioned the previous statement above. I then started to try and force datasheet on the Subform, but I'm not sure Activex likes subforms because it isn't actually finding the part number on the page, even though it technically is attached. Either two things need to happen, but I'm not sure if either of them work or how to write the code for either:
    1 - I have to create a relationship between the Subform and the Form so the DWF viewer can read the PN (don't know if this is true).
    2 - I add a drawpath link to the report that has been sorted in the subform to the report so it can find the full path, in effect, tricking the DWF viewer into searching within the report within itself. I could hide the drawpath behind the viewer so it isn't seen.

    All I have now is:
    Option Compare DatabaseOption Explicit
    Private Sub FindDWF()
    Dim Viewer As IAdPageViewer
    Set Viewer = CEView2.Viewer
    On Error GoTo NoPic
    Dim Strpic As String


    Strpic = Me![PN]
    Strpic = "M:\Part Database\gasketdwgs\" & Strpic & "-Model.dwf"
    If Strpic = Null Then
    Strpic = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    End If
    drawpath.Caption = Strpic
    Me.CEView2.SourcePath = Strpic


    Exit Sub


    NoPic:
    Strpic = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    drawpath.Caption = Strpic
    Me.CEView2.SourcePath = Strpic


    End Sub

    Any new suggestions?

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I then started to try and force datasheet on the Subform, but I'm not sure Activex likes subforms because it isn't actually finding the part number on the page, even though it technically is attached. Either two things need to happen, but I'm not sure if either of them work or how to write the code for either:
    1 - I have to create a relationship between the Subform and the Form so the DWF viewer can read the PN (don't know if this is true).
    If the field [PN] is on a subform, you cannot refer to (capture the value) by referring to it using
    Code:
    Strpic = Me![PN]
    You have to refer to a control on a subform using:
    Code:
    Strpic = Me!Subform1.Form!ControlName
    (change to your subform/control names)

    This site should help you: Refer to Form and Subform properties and controls
    http://access.mvps.org/access/forms/frm0031.htm




    The code looks better... but you cannot check for NULLs using
    Code:
    If Strpic = Null THEN
    Reason: nothing is equal to NULL, not even another NULL. If you executed

    Code:
    IF NULL = NULL Then
    The result will *always* be FALSE

    You have to check for NULLs using other methods:

    Code:
    IF ISNull(Strpic) THEN
    or
    Code:
    IF Len(Trim(Nz(Strpic,""))>0 THEN
    (I prefer to use this method)

    The Nz() function changes a NULL (in this case) to a zero length string.
    The Trim() function removes spaces
    You know what the Len() function does.

  13. #13
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    Quote Originally Posted by ssanfu View Post
    You know what the Len() function does.
    I do? HAHA

  14. #14
    mobius909 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2012
    Posts
    10
    I've decided to post images to possibly help clarify what's going on. I'm not getting any change:

    MAIN : TABLE
    (TYPE is a select-able table-field on the MAIN form)
    Click image for larger version. 

Name:	MAIN TABLE.jpg 
Views:	9 
Size:	207.6 KB 
ID:	8062

    FORM : TYPE
    (TYPE Combo Box (selects from Table TYPE), Button to Preview REPORT : TYPE Query (just data)/, Button to Print REPORT : TYPE Query (data), Button to Preview REPORT : TYPE DWF (dwf eventually), Button to Print REPORT : TYPE DWF and the TYPEQuerySubform (data sorted by TYPE Comb Box))
    Click image for larger version. 

Name:	Form Type.jpg 
Views:	7 
Size:	115.0 KB 
ID:	8063

    TYPE Query
    Click image for larger version. 

Name:	TYPE Query.jpg 
Views:	7 
Size:	123.7 KB 
ID:	8065

    REPORT : TYPE DWF result
    looks like it's reading the ActiveX box in the print, but it's not embedding the .dwf file based on location. the report count at the bottom gives appropriate # of sorted reports and blank printed pages (with the border).
    (the result of pressing the Preview REPORT : TYPE DWF button)
    Click image for larger version. 

Name:	TYPEQuerySubform.jpg 
Views:	7 
Size:	29.2 KB 
ID:	8066

    REPORT : TYPE DWF
    Click image for larger version. 

Name:	REPORT TYPE DWF.jpg 
Views:	7 
Size:	139.9 KB 
ID:	8067

    Current Code on Report : Type DWF

    Option Compare Database
    Option Explicit
    Private Sub FindDWF()
    Dim Viewer As IAdPageViewer
    Set Viewer = CEView2.Viewer
    On Error GoTo NoPic
    Dim Strpic As String


    Strpic = Me![TYPEQuerySubform].Form![PN]
    Strpic = "M:\Part Database\gasketdwgs\" & Strpic & "-Model.dwf"
    If Len(Trim(Nz(Strpic, "")) > 0) Then
    Strpic = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    End If
    drawpath.Caption = Strpic
    Me.CEView2.SourcePath = Strpic
    Exit Sub
    NoPic:
    Strpic = "M:\Part Database\gasketdwgs\DWFTemplate-Model.dwf"
    drawpath.Caption = Strpic
    Me.CEView2.SourcePath = Strpic
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-07-2012, 09:00 AM
  2. Replies: 4
    Last Post: 12-13-2010, 05:33 PM
  3. Replies: 2
    Last Post: 08-25-2010, 01:42 PM
  4. Replies: 3
    Last Post: 05-21-2010, 03:57 PM
  5. Replies: 0
    Last Post: 10-24-2008, 11:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums