Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Question

  1. #1
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80

    Unanswered: Question

    I have a textfield in form that contains a path to a picture. What I need is a piece of code that checks if the path is already in the table, so that there isn't any double values.

    Apparently I need to create a query that returns all the paths and then somehow compare it with the path that is in the form.

    The problem is that I use API to open up a file dialog, so that the user can choose the right file and the path is saved in a textfield.

    So how can I make access check that the path is not in the table already? And I want it to check it out after the user has selected the
    file...

    ------------------------------------------
    code, that opens file dialog and returns the path of selected picture to field called txtKuvanOsoite.
    ------------------------------------------
    Function HaeFile()
    Dim strFilter As String
    Dim strDefaultPath As String

    strDefaultPath = Application.CurrentProject.Path
    Me.txtKuvaOsoite = GetOpenFile(strDefaultPath, "Etsi kuva tiedosto..")
    asetaKuvanOsoite

    End Function

    Function asetaKuvanOsoite()

    On Error Resume Next
    Dim strKuvanOsoite As String

    strKuvanOsoite = Me.txtKuvaOsoite
    Me.KuvaFrame.Picture = strKuvanOsoite

    End Function
    ------------------------------------------

  2. #2
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Please help! Tomorrow is the last day when I'm working with this database. After that it's out of my hands...

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Wink Re: Question

    Originally posted by Sham81
    I have a textfield in form that contains a path to a picture. What I need is a piece of code that checks if the path is already in the table, so that there isn't any double values.

    Apparently I need to create a query that returns all the paths and then somehow compare it with the path that is in the form.

    The problem is that I use API to open up a file dialog, so that the user can choose the right file and the path is saved in a textfield.

    So how can I make access check that the path is not in the table already? And I want it to check it out after the user has selected the
    file...

    ------------------------------------------
    code, that opens file dialog and returns the path of selected picture to field called txtKuvanOsoite.
    ------------------------------------------
    Function HaeFile()
    Dim strFilter As String
    Dim strDefaultPath As String

    strDefaultPath = Application.CurrentProject.Path
    Me.txtKuvaOsoite = GetOpenFile(strDefaultPath, "Etsi kuva tiedosto..")
    asetaKuvanOsoite

    End Function

    Function asetaKuvanOsoite()

    On Error Resume Next
    Dim strKuvanOsoite As String

    strKuvanOsoite = Me.txtKuvaOsoite
    Me.KuvaFrame.Picture = strKuvanOsoite

    End Function
    ------------------------------------------
    What I understood, you store the path in a Table and the user chooses his path using the API, right.
    Then you can make something like that in the after Update of the path TextField:

    DIM ss as string
    dim db as DataBase, RS as RecordSet
       ss= "SELECT * FROM myTable WHERE myPath=" & Forms("YourFormname").yourPathTextBox & ";"
       DoCmd.RunSql(ss)
       SET db= CurrentDB
       SET RS = db.OpenRecordSet(ss, dbOpenSnapshot)
       RS.moveLast : RS.MoveFirst
      IF RS.RecordCount > 0 then
         MesBox("Path Already Exist")
         MORE CODE FROM U
      Else
         CODE FOR ELESE
      EndIf


    Hope this could help you till tomorrow {the last Day}

  4. #4
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Yeah, you understood correctly, but there's something wrong...

    I copy/pasted your code in the after update event of the textfield and changed the names of the forms, fields etc. When I run the code, it doesn't do anything, no error messages - nothing...

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Sham81
    Yeah, you understood correctly, but there's something wrong...

    I copy/pasted your code in the after update event of the textfield and changed the names of the forms, fields etc. When I run the code, it doesn't do anything, no error messages - nothing...
    Try to make a Break point and trace it, seeing the values of the variables.

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Sorry I have to go now, if you want , you can send a copy in Access 97

    Good luck tomorrow

  7. #7
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Yeah, I'll try that tomorrow. Time to go home...

    Thanks for your help!

  8. #8
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    After trying out all kinds of thing with the code I found out that my code (the one that stores the path in textfield) doesn't seem to trigger the after update-event. After I wrote the path by hand, the code started to run (I know this because it gave me error messages). So, what should I do in order to get the code work as it's supposed to?

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Sham81
    After trying out all kinds of thing with the code I found out that my code (the one that stores the path in textfield) doesn't seem to trigger the after update-event. After I wrote the path by hand, the code started to run (I know this because it gave me error messages). So, what should I do in order to get the code work as it's supposed to?
    Sorry I can't feel your error, you can send a copy in Access 97 if you want.

  10. #10
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Here's the database. I removed the unnecessary parts so it would be easier to understand.
    Attached Files Attached Files

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Sham81
    Here's the database. I removed the unnecessary parts so it would be easier to understand.

    Try this, it brings some error but I think because of the forigner letters such as this o with two points Öö
    Attached Files Attached Files

  12. #12
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    Ok, thanks... I'll try it.

  13. #13
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    I tryied to open the database in access 97 format and it didn't open at all, so I converted it in access 2002 format and got these conversion errors:

    Database: Missing or broken VBE reference to the file 'dao2535.tlb'.

    Module: There were compilation errors during the conversion or enabling of this database.@This might be due to old DAO syntax that is no longer supported.
    For an example on how to fixup the code, click Help. @@2@611705@1

    Module: There were compilation errors during the conversion or enabling of this database.

  14. #14
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by Sham81
    I tryied to open the database in access 97 format and it didn't open at all, so I converted it in access 2002 format and got these conversion errors:

    Database: Missing or broken VBE reference to the file 'dao2535.tlb'.

    Module: There were compilation errors during the conversion or enabling of this database.@This might be due to old DAO syntax that is no longer supported.
    For an example on how to fixup the code, click Help. @@2@611705@1

    Module: There were compilation errors during the conversion or enabling of this database.

    Perhaps you should go in the prefernces and change that DAO 2.5, I've checked it.

  15. #15
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by hammbakka
    Perhaps you should go in the prefernces and change that DAO 2.5, I've checked it.
    Sorry I have 2 go now.
    Good luck

Posting Permissions

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