-
May 11th, 2017, 02:20 AM
#1
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.
-
May 17th, 2017, 09:29 PM
#2
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.
-
May 18th, 2017, 06:26 AM
#3
Re: Or in Where Clause MS Access Vba Code
Originally Posted by DataMiser
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|