473,396 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Active X Control

489 256MB
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

8 2541
CD Tom
489 256MB
I forgot to mention that I'm using Access 2007. Sorry about that.
Dec 7 '11 #2
ADezii
8,834 Expert 8TB
  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
CD Tom
489 256MB
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
8,834 Expert 8TB
'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
CD Tom
489 256MB
Work perfect thanks again for all your help.
Dec 8 '11 #6
ADezii
8,834 Expert 8TB
@CD Tom
You are quite welcome, CD Tom.
Dec 8 '11 #7
CD Tom
489 256MB
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
CD Tom
489 256MB
That was my problem the network computer that I was trying to connect to wasn't turned on. Sorry,
Dec 8 '11 #9

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

Similar topics

3
by: Robert Neville | last post by:
How do you return the last Active Control when the control is on a tab control? Screen.ActiveControl does not seem to work. Here's the statement that my code uses. Set ctlOld =...
2
by: Georges Heinesch | last post by:
Hi. Is it possible to change the position of the cursor inside an active control? In my example ... Me!txtControl.Text = Me!txtControl.Text .... puts the cursor to the left side of the...
3
by: Hank | last post by:
On one of my forms I display a histogram representing the status of jobs in our factory. It's configured as a stacked bar which I create using labels of different background colors. 75 labels are...
6
by: Woody Splawn | last post by:
I know that I can do the following to identify the parent name of an active control Dim sParentName As String = ActiveControl.Parent.Name But how do I identify the name of the active control?...
4
by: Volker Jobst | last post by:
Hi, Is there an event of windows.forms.form which informs me that the active control will be changed before it will be changed? Something like: Private Sub Form_Validating(ByVal sender As...
0
by: Mark Chen | last post by:
Hello : My problem is my active control will download to IE6 sp2, but not download to IE6 sp1. On IE6 sp1, ther is no popup to ask for download. Mark
1
by: rayne | last post by:
hi I'm just new in making code using visual basic. I just want to know what do you mean by active control and how does it work. thanks
2
by: Randy | last post by:
I have a form on which various controls are added dynamically depending on actions of the user. One of these actions allows the user to click a delete button that will remove various other...
7
by: Neil | last post by:
I have some code in my form's On Current event which changes focus to a particular control. I want the control to remain where it was when the user moved to the new record. But using...
7
by: Andrus | last post by:
I have UserControls in MDI child forms containing TextBoxes and other controls. When user re-activates form, I need that Control which was last activated is activated again. Currently *first*...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.