Results 1 to 12 of 12

Thread: [RESOLVED] Where is common dialog?

  1. #1

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Resolved [RESOLVED] Where is common dialog?

    I've just copied my Database to my laptop which is running the exact same version of MS Access (XP) and the common dialog control is missing.
    Also, some other parts of my code aren't working. I'm getting errors with some declarations.
    Hmmm. Frustrating...
    Last edited by OllieVB; Feb 6th, 2006 at 02:57 AM. Reason: typo
    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Where is common dialog?

    You probably manually added the cdl to your toolbox. So that means you need to do the same for the copy on your other system. When you manually add references and controols you need to also include them with the database where ever your deploy it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Re: Where is common dialog?

    Thanks for that info. Just one problem... On the laptop, the ActiveX controls list doesn't include the common dialog control, even though it's an identical Office install. When I used it on my desktop PC, it was already in the list and ready to use. How do I find the control so I can copy it across with the database and can it be somehow embedded?
    (I do not have the ability to 'pack and go' my database in runtime format and have to have Access installed on whichever PC is going to run it at the moment)
    Last edited by OllieVB; Feb 6th, 2006 at 05:00 AM.
    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Where is common dialog?

    The commondialog control is included with VB 6 so does your development system have VB installed on it? That could be why its on one and not the other. You can download it from the VB6 runtime redistributables but then it will install all the runtimes, etc.

    You can create a dialog of your own using VBA. .GetOpenFilename .GetSaveAsFilename
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Where is common dialog?

    Office XP also comes with built in fileopen commands, but you will need the reference to MS Office itself for it to work correctly..

    Quote Originally Posted by Access VBA Help
    FileDialog Property
    Returns a FileDialog object which represents a single instance of a file dialog box.

    expression.FileDialog(dialogType)

    expression Required. An expression that returns one of the objects in the Applies To list.

    dialogType Required MsoFileDialogType. The type of file dialog box.

    MsoFileDialogType can be one of these MsoFileDialogType constants.
    • msoFileDialogFilePicker

    • msoFileDialogFolderPicker

    • msoFileDialogOpen

    • msoFileDialogSaveAs


    Example
    This example displays the Save As dialog box.
    VB Code:
    1. Dim dlgSaveAs As FileDialog
    2.  
    3. Set dlgSaveAs = Application.FileDialog( _
    4.     FileDialogType:=msoFileDialogSaveAs)
    5.  
    6. dlgSaveAs.Show

    This example displays the Open dialog box and allows a user to select multiple files to open.
    VB Code:
    1. Dim dlgOpen As FileDialog
    2.  
    3. Set dlgOpen = Application.FileDialog( _
    4.     FileDialogType:=msoFileDialogOpen)
    5.  
    6. With dlgOpen
    7.     .AllowMultiSelect = True
    8.     .Show
    9. End With
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  6. #6

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Thumbs up Re: Where is common dialog?

    Thanks again guys for your help. Don't mean to drag this out, but can you specify a default filename for each of these?
    ... Sorted this bit now!

    Also, is there a similar method for calling up the print dialog box?

    I might be better off posting this in the database area but I thought I would give it a try here first as you've been so helpful!

    Last edited by OllieVB; Feb 7th, 2006 at 05:43 AM.
    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

  7. #7

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Unhappy Re: Where is common dialog?

    I've done some digging in the MSDN library after these wise words but there' still something I just can't find. Here's my code using the FileDialog Object:

    VB Code:
    1. Private Sub Backup_Click()
    2.  
    3.         Dim fd As FileDialog
    4.         Dim FileDest As Variant
    5.      
    6.         Set fd = Application.FileDialog(msoFileDialogSaveAs)
    7.         FileDest = ""
    8.        
    9.         With fd
    10.             .InitialFileName = "backup.mdb"
    11.             .Title = "Backup records to..."
    12.             .Show
    13.             FileDest = .SelectedItems
    14.         End With
    15.  
    16.         'Test for filename
    17.         MsgBox "You selected: " & FileDest
    18.  
    19. End Sub

    ... but the .Selected Items is wrong. Can you tell me what is the correct way to get the full path and filename into the variant 'FileDest'?
    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

  8. #8
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Where is common dialog?

    Quite simply add (1) at the end of SelectedItems

    VB Code:
    1. FileDest = .SelectedItems(1)

    You can leave the .InitialFileName blank to force your users to specify a filename as well as the filepath.
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  9. #9
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Where is common dialog?

    Incidently to display the Print Dialog so that your users can specify where to print to you can use..

    VB Code:
    1. DoCmd.RunCommand acCmdPrint

    However it's not that simple.. It will depend on what you are trying to print.

    I tend to use a sub procedure in a module that is called from anywhere within the database.. this then sets a flag for the report to specify whether or not to print or display..

    VB Code:
    1. Sub NewPrintingMethod(strReportName As String)
    2.   'Procedure will attempt to open the requested report for printing, allowing the user the option of choosing their printer before printing the report
    3.   On Error GoTo NewPrint_Err
    4.   DoCmd.OpenReport strReportName, acViewPreview
    5.   On Error GoTo 0
    6.   If ReportPrinted = False Then
    7.     If NoRepData = False Then
    8.       If vbYes = MsgBox("You have not printed this report, do you want to try again?", vbCritical + vbYesNo, "REPORT NOT PRINTED") Then
    9.         NewPrintingMethod strReportName
    10.       End If
    11.     Else
    12.       NewPrintingMethod strReportName
    13.     End If
    14.   End If
    15.   Exit Sub
    16.  
    17. NewPrint_Err:
    18.   'report contained no data try again
    19.   On Error GoTo 0
    20.   NewPrintingMethod strReportName
    21.   Exit Sub
    22. End Sub

    This is called with the name of the report to be printed.. the PrintingReport and NoRepData are two Public Defined Boolean Variables in the Same module. PritingReport is set to True and instead of opening the report for print view this sub is called like so..

    VB Code:
    1. PrintingReport = True
    2.   NewPrintingMethod "ReportName"
    3.   PrintingReport = False

    Behind the report is the following code that handles whether or not the report is to be printed or to allow normal view..

    VB Code:
    1. Private Sub Report_Activate()
    2.   NoRepData = Not HasData
    3.   If NoRepData Then Exit Sub
    4.   If Not PrintingReport Then
    5.     DoCmd.Maximize
    6.     Exit Sub
    7.   End If
    8.   On Error GoTo Err_Report_Activate
    9.   DoCmd.RunCommand acCmdPrint
    10.   ReportPrinted = True
    11.   DoCmd.Close acReport, Me.Name
    12.   Exit Sub
    13.  
    14. Err_Report_Activate:
    15.   ReportPrinted = False
    16.   DoCmd.Close acReport, Me.Name
    17.   On Error GoTo 0
    18.   Exit Sub
    19. End Sub
    20. Private Sub Report_NoData(Cancel As Integer)
    21.   NoRepData = True
    22.   Cancel = True
    23. End Sub

    The NoRepData is handled inside the Report_NoData Event like above.. this forces the printing method to try again.. To stop this from happening I normally add a check on the report's source data before calling this sub to ensure that there is some data in the table/query for the report..

    Hope this helps.
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  10. #10

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Re: Where is common dialog?

    Danny,

    Two things...

    Firstly, I'm afraid that putting (1) after the .SelectedItems didn't work. It just gave the same error!

    Secondly, I've already got the code to print and preview the report. So I don't start throwing out loads of paper, does you single line of code make the printer dialog appear before printing?

    Why does all this stuff have to be so complicated
    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

  11. #11
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Where is common dialog?

    Hmmm

    Should work with the (1).. if not try .SelectedItems.Items(1), or if using option base 0 then you will need to use (0)..

    Or if in doubt just do

    VB Code:
    1. Dim i
    2. 'rest of your code
    3. For i = 1 to .SelectedItems.Count
    4.   Msgbox .SelectedItems.Item(i)
    5. Next i

    The single line of code will not work in access as you will need to open the report first.. You can place that single line into the report_Activate event, but it will display the print dialog even when opening the report in page preview mode..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  12. #12

    Thread Starter
    Junior Member OllieVB's Avatar
    Join Date
    Jan 2006
    Location
    England, UK
    Posts
    24

    Cool Re: Where is common dialog?

    Danny,

    Finally got it working as you suggested. It was all down to one little word missing...

    In your posting, you said I needed to put (1) after the .SelectedItems, but actually it needed .Item(1) after it! Still, I wouldn't have got there if it wasn't for your invaluable help so thanks very much for that.

    Ollie
    Mess with the bull... You get the horns!
    ... Windows XP Home SP2
    ... Visual Basic 6 Professional Edition
    ... Office 2003 SP2 Professional Edition

    I will always leave a good response to helpful postings... They are a lifeline!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width