By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,508 Members | 2,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,508 IT Pros & Developers. It's quick & easy.

Active X Control

100+
P: 434
Here's my problem. My application is running great on windows 7, when I try and move it to an XP machine the browse command doesn't work. I use the browse command to when I am trying to relink the database. I have a button on a form to browse for the database, when the database is found I then have another button to link the new location of the database. When I look at the form on my Windows 7 machine I see the active X Control the OLE class is commondialog the Class is MSComDlg.CommonDialog.1 when I look at the form on my XP machine this control isn't there. I don't know how to add that control, can anybody help.
Thanks.
Dec 7 '11 #1

✓ answered by ADezii

'First, set a Reference to the Microsoft Office XX.X Object Library
Expand|Select|Wrap|Line Numbers
  1. Dim strButtonCaption As String
  2. Dim strDialogTitle As String
  3. 'Dim strHyperlinkFile As String
  4.  
  5. 'Define your own Captions if necessary
  6. strButtonCaption = "Open"
  7. strDialogTitle = "Select Access Database to Link"
  8.  
  9. With Application.FileDialog(msoFileDialogFilePicker)
  10.   With .Filters
  11.     .Clear
  12.     .Add "Access Databases", "*.mdb,*.accdb"
  13.   End With
  14.   'The Show Method returns True if 1 or more files are selected
  15.     .AllowMultiSelect = False                   'Critical Line
  16.     .FilterIndex = 1                            'Database files
  17.     .ButtonName = strButtonCaption
  18.     .InitialFileName = vbNullString
  19.     .InitialView = msoFileDialogViewDetails     'Detailed View
  20.     .Title = strDialogTitle
  21.   If .Show Then
  22.     'The Absolute PATH to the Selected Database is contained in .SelectedItems(1)
  23.     'You now have all you need to initiate the Link
  24.      MsgBox "You have selected [" & .SelectedItems(1) & "] to Link"
  25.   End If
  26. End With

Share this Question
Share on Google+
8 Replies


100+
P: 434
I forgot to mention that I'm using Access 2007. Sorry about that.
Dec 7 '11 #2

ADezii
Expert 5K+
P: 8,600
  1. Why use an ActiveX Control in the first place? The simpler, and safer Office File Dialog would serve the same purpose, wouldn't it?
  2. Why not incorporate the Browse and Link Operations into a single process, as opposed to two?
Dec 7 '11 #3

100+
P: 434
That sounds like a great idea. Is there a sample somewhere that I could copy or can you point me to where I could find how to do this.
Dec 7 '11 #4

ADezii
Expert 5K+
P: 8,600
'First, set a Reference to the Microsoft Office XX.X Object Library
Expand|Select|Wrap|Line Numbers
  1. Dim strButtonCaption As String
  2. Dim strDialogTitle As String
  3. 'Dim strHyperlinkFile As String
  4.  
  5. 'Define your own Captions if necessary
  6. strButtonCaption = "Open"
  7. strDialogTitle = "Select Access Database to Link"
  8.  
  9. With Application.FileDialog(msoFileDialogFilePicker)
  10.   With .Filters
  11.     .Clear
  12.     .Add "Access Databases", "*.mdb,*.accdb"
  13.   End With
  14.   'The Show Method returns True if 1 or more files are selected
  15.     .AllowMultiSelect = False                   'Critical Line
  16.     .FilterIndex = 1                            'Database files
  17.     .ButtonName = strButtonCaption
  18.     .InitialFileName = vbNullString
  19.     .InitialView = msoFileDialogViewDetails     'Detailed View
  20.     .Title = strDialogTitle
  21.   If .Show Then
  22.     'The Absolute PATH to the Selected Database is contained in .SelectedItems(1)
  23.     'You now have all you need to initiate the Link
  24.      MsgBox "You have selected [" & .SelectedItems(1) & "] to Link"
  25.   End If
  26. End With
Dec 7 '11 #5

100+
P: 434
Work perfect thanks again for all your help.
Dec 8 '11 #6

ADezii
Expert 5K+
P: 8,600
@CD Tom
You are quite welcome, CD Tom.
Dec 8 '11 #7

100+
P: 434
I just ran into a problem. When I try and select a mapped drive I get an error message The drive "M:" is not valid. Enter a valid drive letter. The only drive I can select is the C drive. What do I need to do so I can select any drive.
Again thanks for your help.
Dec 8 '11 #8

100+
P: 434
That was my problem the network computer that I was trying to connect to wasn't turned on. Sorry,
Dec 8 '11 #9

Post your reply

Sign in to post your reply or Sign up for a free account.