Results 1 to 4 of 4

Thread: 2 Questions. Read my questions! Thank u.

  1. #1

    Thread Starter
    Join Date
    Nov 1999


    I have an image and a text on the form. I created a project that generates random pictures. Here is the below code in the form --
    Private Sub Form_Load()

    Randomize Timer
    imgSign.Picture = LoadPicture(App.Path & "\sign" & Int(Rnd * 10) + 1 & ".jpg")

    End Sub

    But my question is how to select a random description(perhaps from a file), and it must match with the image.

    i.e. the image randomly displays "cat, and the text randomly shows the definition of "cat" on the form .... it has to be matched with an image "cat"

    I created the database in Access 97, and I got the code to define Word and Picture and Text

    field name data type
    word text
    picture ole object
    description memo

    I added the data. And, the result are shown below

    word picture description

    cat picture an animal....
    dog picture an animal....
    car picture an automobile....
    etc etc etc.......

    But, I have the code, and I ran the program.. it says, "Unable to bind to field or DataMember. "Picture". I used the Data Form Wizard to create a form using the Employeers from the NWind.mdb database --- includes the pictures. When I ran that frmEmployeers, I got the same error!! I did not understand what does it mean by "Unable to bind....!" Can anyone tell me??? Thanks in advance.

    I am new to this BB. How do I respond back to someone's reply. Thank u.

  2. #2
    Addicted Member
    Join Date
    May 1999
    Californ-I- A


    I know nothing about databases, but what I would do is create an INI file with the definitions corresponding with the image filenames. Fore example,

    Dim iResult as string
    iResult = space(255)
    dim iDefault as string
    iDefault = "Unable to read from INI file."

    txtDefinition.text = getprivateprofilestring(imgWhatever.picture, "Definition" , iResult, len(iResult), "iDefault")

    and then have the ini file look like this ...

    definition=meow meow meow

    definition=bark bark bark

    Just an idea, I'm no expert. If you take that route, don't forget to declare:

    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

    Good luck,
    Micah Carrick

  3. #3
    New Member
    Join Date
    Jun 1999


    Personally I would stick with the database idea it is more flexible and neater looking from an end user perspective than an INI (in my opinion).

    I'm assuming that you have managed to open and read from the database that you have created, right? If that is the case I would look into opening the database with a SQL statement that selects only the record associated with the picture. As for storing the images, I would keep them seperate like you were doing originally rather than trying to embed the information into the database.

    Micheal Blackthorne

  4. #4

    Thread Starter
    Join Date
    Nov 1999


    I got my code working! Thanks so much for all of your help!

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