Results 1 to 3 of 3
  1. #1
    ron727 is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2009
    Posts
    7

    ComboBox to update picture

    Hello all I currently have a database using access 2007 where i have a table with countryList to populate a combo box to select a country on my form. This combo box is linked to an image control that displays the flag of the country selected. The pictrues are linked to a folder on drive c: called Flags. Now my problem is the following: When i choose the country the picture disp[lays properly using an after update event. However when i open the form with a record the flag does not display. So i added code to the current event on the form and it does not work. I want that if a country is selected that is shows the flag of the country and if no country is selected i want the picture to display a defaulf flag icon.

    Here is the code:

    Private Sub Combo29_AfterUpdate()

    Dim strPath As String
    strPath = Me.Combo29.Column(2)
    Image31.Picture = strPath

    End Sub

    The above part work perfectly..........

    This part below is where the problem lies...

    Private Sub Form_Current()

    Dim strPath As String
    Dim defPath As String

    defPath = "c:\Flags\Default.jpg"
    strPath = Me.Combo29.Column(2)



    If Me.Combo29.Column(2) <> Null Then

    Image31.Picture = strPath
    Else
    Image31.Picture = defPath

    End If

    End Sub

    I get error 94 inproper use of Null

    Where am i going wrong

    PS I am new to programming VBA (obviously)

    Thanks

    Ron

  2. #2
    ron727 is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2009
    Posts
    7
    forget my above post i used a workaround solution using default value

    Thank you

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    To answer your question, *nothing* is ever = to Null, including another Null. So:
    If Me.Combo29.Column(2) <> Null Then ...will always be true. That's why we have the IsNull() function. If Not IsNull(Me.Combo29.Column(2)) Then ...would probably have served you here.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 05-19-2009, 04:15 PM
  2. Inserting a picture
    By Carenas in forum Forms
    Replies: 0
    Last Post: 01-03-2009, 05:09 PM
  3. Replies: 0
    Last Post: 04-17-2008, 09:24 AM
  4. query based on two combobox
    By datto in forum Queries
    Replies: 0
    Last Post: 04-18-2007, 11:10 PM
  5. Selecting text - ComboBox
    By Numbat in forum Programming
    Replies: 2
    Last Post: 06-05-2006, 05:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums