CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2017
    Posts
    2

    Post Or in Where Clause MS Access Vba Code

    Can anyone help me in Where Clause?

    I have three fields Country,Product, and Year in Table Cap.
    I have added Combobox in form for these field and also search button.
    I want that if one combo box value is selected and search button is click it should display all record for related combo box.
    ....
    Button Click Code:

    Search = "Select * from Cap where ([Country]= '" & Me.Combo6 & "' OR [Product]= " & Me.Combo15 & " OR [Years]= " & Me.Combo25 & " )"
    Me.sfrmCap.Form.RecordSource = Search
    Me.sfrmCap.Form.Requery

    It gives Run time error 3075.

    Any help would be appreciated.

    Thank you.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Or in Where Clause MS Access Vba Code

    what is the error message?

    Are both of those last two fields numeric in the database?
    What values are in the combos when you get the error.

    Note if those fields are numeric then searching for an empty string is not valid and would be the case if nothing is selected in the related combos.
    You may need to use some If statements to modify the select based on what is selected rather than just throwing it all into the one statement.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    May 2017
    Posts
    2

    Re: Or in Where Clause MS Access Vba Code

    Quote Originally Posted by DataMiser View Post
    what is the error message?

    Are both of those last two fields numeric in the database?
    What values are in the combos when you get the error.

    Note if those fields are numeric then searching for an empty string is not valid and would be the case if nothing is selected in the related combos.
    You may need to use some If statements to modify the select based on what is selected rather than just throwing it all into the one statement.
    ....


    Thank you , it's solved

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

Featured