Results 1 to 1 of 1

How to populate a text box in the details form from a combo box

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-05-2011
    Location
    behind you!
    MS-Off Ver
    Excel 2010
    Posts
    116

    How to populate a text box in the details form from a combo box

    Hi all,

    please have a look on the attached screen shot!

    By changing the selection in the combo box I'll get run time error '3464': "Data type mismatch in criteria expression."

    The idea is:

    1. The user selects a strategy name (e. g. dfgsdfgfdsg) from the combo box.
    2. A marco reads out the according Strategies.ID from Strategies.
    3. Based on this ID the according Keyords will be read from Strategy.
    4. I want to populate the text box in the detail section with the entries of the Variant-Array created in step 3.

    Here is my code:

    Private Sub Strategy_CoBo_Change()
    
        Dim SQL As String
        Dim StrategiesID As Integer
        'Dim StratKW As Variant
        'Dim i
    
        SQL = "SELECT ID FROM Strategies where Name=" & Chr(34) & Me.Strategy_CoBo.Value & Chr(34)
        StrategiesID = DBREAD(SQL)(0) 'Integer indentifies the Strategy
        'SQL = "SELECT Keyword FROM Strategy where ID=" & StrategiesID & " Order by Keyword"
        'StratKW = DBREAD(SQL)
        'Me.DetailKeyword.Value = StratKW(0)
    
        Me.DetailKeyword.Value = DLookup("[Keyword]", "Strategy", "[ID] = '" & Me.Strategy_CoBo.Value & "'")
    
        'For i = LBound(StratKW) To UBound(StratKW)
        '    Me!Detail.Form.DetailKeyword = StratKW(i)
        'Next i
        
    End Sub
    What I am doing wrong?

    Thank you very much,
    Lloyd
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1