473,320 Members | 1,848 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,320 software developers and data experts.

Problem: Connecting a linkLabel to files in MsAccess

LanaAlana
1) choose a chemical from the combobox
2) click on search button - all details of chemical appear in respective places
3) next, i would require a link label to be clicked on to bring me to the specified chemical file because each chemical has its own special file

Its like each time I search for chemical A, the link label will show chemical A's file upon clicking it.
and if I were to search another chemical, chemical B,the link label will show chemical B's file upon clicking it.

Problem: i'm figuring out how to connect my linklabel to open the specified chemical's file link which is stored in ms access.

In my access table, I have a table with two columns;
1st column: All chemical Names
2nd Column: Contains all the links to the chemical files that i want to open in the task above.

Code I have done so far which is left hanging coz, I don't know how to modify it,
Expand|Select|Wrap|Line Numbers
  1. Public Function linktoMSDS(ByVal Link_To_MSDS As String)
  2.         Dim strSql As String
  3.         Dim dstemp As New DataSet
  4.  
  5.  
  6.         Try
  7.             build()
  8.             strSql = "Select [Link to MSDS] from tblChemical where [Link To MSDS] = '" & Link_to_MSDS & "'"
  9.  
  10.             myCommand = New OdbcCommand(strSql, myConn)
  11.             myCommand.CommandTimeout = 50
  12.  
  13.             myAdapter = New OdbcDataAdapter
  14.             myAdapter.SelectCommand = myCommand
  15.  
  16.             connect()
  17.  
  18.             myAdapter.Fill(dstemp, "tblChemical")
  19.             Return dstemp
  20.         Catch ex As Exception
  21.             Try
  22.  
  23.             Catch odbcEx As OdbcException
  24.                 MessageBox.Show(odbcEx.Message & odbcEx.StackTrace)
  25.             End Try
  26.             MessageBox.Show(ex.Message, ex.StackTrace)
  27.             Return dstemp
  28.         Finally
  29.             disconnect()
  30.         End Try
  31.  
  32.     End Function
Expand|Select|Wrap|Line Numbers
  1.  Dim dsChemical As New DataSet
  2.         dsChemical = New DataSet
  3.         Dim strlink_to_MSDS As String
  4.         Dim i As Integer
  5.  
  6.  
  7.         If dsChemical.Tables("tblchemical").Rows.Count > 0 Then
  8.             If txtchemname.Text = dsChemical.Tables(0).Rows(0)("Chemical Name") Then
  9.                 For i = 0 To dsChemical.Tables(0).Rows.Count - 1
  10.                     strlink_to_MSDS = dsChemical.Tables(0).Rows(0)(4)("Link to MSDS")
  11.  
  12.  
  13.  
  14.                 Next
  15.             End If
  16.         End If
  17.  
  18.     End Sub
  19.  
Oct 12 '11 #1
7 2137
Frinavale
9,735 Expert Mod 8TB
Does the "link column" contain a path to a physical file located somewhere on the person's computer?

Or does the "link column" have binary information that is the file itself?

I'm not sure what data is stored in your "link column".
Oct 12 '11 #2
Oh sorry didn't mention it..It contain a path to a physical file of located somewhere on the person's computer.
Oct 13 '11 #3
Frinavale
9,735 Expert Mod 8TB
Add a method that handles the LinkLabel's LinkClicked event.

In that method, retrieve the file that you want to open.
If you aren't storing the path information in the link's text, then retrieve the path from the database upon clicking the link based on the selected value in the combobox or something.

-Frinny
Oct 13 '11 #4
Expand|Select|Wrap|Line Numbers
  1. Private Function linktoMSDS_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles linktoMSDS.LinkClicked
  2.  
  3.         'Dim strMSDS As String
  4.         Dim dsChemical As New DataSet
  5.         dsChemical = New DataSet
  6.         Dim strMSDS As String
  7.         Dim Link_to_MSDS As String
  8.  
  9.         If cmbchemicalname.Text <> "" Then
  10.             dsChemical = connecttoMSDS(Link_to_MSDS As String)As Object
  11.  
  12.             If dsChemical.Tables("tblchemical").Rows.Count = 1 Then
  13.                 If txtchemname.Text = dsChemical.Tables(0).Rows(0)(1)("Chemical Name") Then
  14.                     strMSDS = dsChemical.Tables(0).Rows(0)(4)("Link to MSDS")
  15.  
  16.                     System.Diagnostics.Process.Start(strMSDS)
  17.  
  18.                 End If
  19.             End If
  20.         End If
  21.  
  22.  
  23.     End Function
  24.  
But I don't really know how translate what I wanted to do into codes. Can you help me by showing me examples how to do it?
Oct 14 '11 #5
Hi Frinny,
I'm suppose to open a file directly when I click the linklabel
without having to go through the directory like the code below...

Expand|Select|Wrap|Line Numbers
  1.  If openFD.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  2.             MessageBox.Show("File Selected ")
  3.             Dim temp_string As String
  4.             Dim a As Integer
  5.             temp_string = openFD.FileName
  6.             temp_string = temp_string.Substring(0, temp_string.Length - 4)
  7.             a = temp_string.LastIndexOf("\")
  8.             strFileName = openFD.FileName
  9.  
  10.         ElseIf System.Windows.Forms.DialogResult.Cancel Then
  11.             MsgBox("No File Selected")
  12.         End If
  13.  
And using,

Expand|Select|Wrap|Line Numbers
  1. System.Diagnostics.Process.Start
Will only allow me to open one file.

How can I come out with a code that allows the linklabel to change path as the user search for a new chemical?
Oct 20 '11 #6
NeoPa
32,556 Expert Mod 16PB
@Lana
Frinny is unavailable for a number of days so is unlikely to respond further in that time. Another expert may come along to assist, but if not I suggest you give some further thought to what's already been posted and see what you can manage to resolve in that time.

Best of luck.
Oct 21 '11 #7
CroCrew
564 Expert 512MB
Hello LanaAlana,

Have you figured out your problem yet? I will be willing to provide you with help till Frinny gets back. Just let me know.

Happy Coding,
CroCrew~
Oct 31 '11 #8

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

Similar topics

1
by: Kajol | last post by:
Hi I am facing a strange problem in downloading files from the web. CASE 1: I have an ActiveX.dll file developed using Visual Basic 6.0 and uploaded on a Linux Server. I am typing...
3
by: Ladykiller | last post by:
Hi everybody , I'm writing because i'm new in C++ and i have a big problem , I want my program to find files in a directory, (*.jpg, for example)and create alist of these files, Does anybody...
4
by: Ian Davies | last post by:
Hello all The following code allows me to connect to a local MySQL database on my pc from a VB6 project. **************************************************************************** ** Dim...
4
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
1
by: davidman73 | last post by:
Hello, I have VS 2005 with SQL Server Express in the same machine, but need to connect to a remote SQL Server 2000. I'm getting this error: An error has occurred while establishing a...
9
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
0
by: mortenol | last post by:
Hi, I am trying to connect a MS SSIS package to an AS400/DB2 database, and I experience problem when I hit the "Create Package" button in the "Data Link properties window". I have understood that...
6
by: Joe Adams | last post by:
I am attempting to reinstall from a windows gone bad problem. XP had "died" and unable boot into os, so there was no backup or copy database made. Have installed new hdd. copied most all of the...
2
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to...
8
by: Daveo | last post by:
Dear all, We recently migrated a SQL database from one server to another. Now, when you try to run some code in an Access Database which links to the SQL one, you get a 3704 error "Operation is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.