469,271 Members | 895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Search Form Code

hi, i have a master table with all my part information, and it has columns with part number, date, defects,...
and i am trying to write a code for my search form.
i have created a search form on Access, and it has 5 combo boxes for:
part number
assembled by
and the other 2 combo boxes are for "from" and "to" date range. i have made the combo boxes for the date range to display a calendar when clicked and choose a date.

i have been trying to write a code that only requires one of these fields to be filled out and it can filter my master table.
i would appreciate any help on this
Aug 9 '10
61 3402
32,171 Expert Mod 16PB
You are talking as if you don't know the difference between VBA code and SQL code.

Earlier, we were talking about VBA code. We created a SQL filter string within this VBA to apply to the RecordSource of the form. The RecordSource would basically be a SQL string. The event procedures we've been working in though, would be VBA.
Aug 16 '10 #51
i have been trying to manipulate the vba code into my search query but im running into a lot of problems.
i know that all i need to have are lines # 2, 6, 12, 17 from post #20
but i cant seem to have the right sql for it.
i was wondering if u had an example or anything that might help.

Aug 17 '10 #52
32,171 Expert Mod 16PB
I get the feeling you're not paying attention to what I post again. You keep coming back at me with stuff that makes no sense. I am trying to clarify things by asking important questions, designed to help me understand what you're talking about. If you ignore this and try to explain again in the same way as before we will get nowhere (Obviously. If I could understand you explaining it that way, there would be no need for the clever questions in the first place).

Either respond to my posts or I cannot help you. I can only help you to a certain extent to say what you need in a way that makes sense. If you ignore me then I can't help at all, and if I don't know what you're talking about I can't help technically either.

It's quite simple really.
Aug 18 '10 #53
im not sure what questions i exactly missed, but i'll try to explain what i am having difficulty with.
for example if i take this code below:
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.Defect) Then _
  2.        strFilter = strFilter & " AND " & "('" & Me.Defect & "' In([Defect Code 1]," & "[Defect Code 2]," & "[Defect Code 3]))"
how can i make this code in sql language?
i have been trying to put it in the "select, where" format, but it doesn't seem to be correct
Aug 18 '10 #54
one more question, what is the purpose of having this search query when i have the vba code for my search form. would i be able to make my search form function without the query
Aug 19 '10 #55
32,171 Expert Mod 16PB
It seems to me you're still confused over the difference between SQL and VBA, but you ignored my post where I attempted to clarify this with you then simple carried on regardless.

Frankly, I find the first problem needs very careful handling, which is entirely impossible unless I have your full attention. Simply ignoring it and hoping it will go away is not going to make for good (any) progress. Trying to proceed from that point is unwise in the extreme. To illustrate, it's like finding someone to ask for help, and when you find they only speak Eskimo, going on to ask them to explain Einstein's Special Theory of Relativity. It matters nothing how important it is for you to understand it. You will not understand what they say anyway, and they have no idea what you're asking.
Aug 24 '10 #56
F430, are you using the program Access by Microsoft or are you using SQL by Microsoft or perhaps you are in Visual Basic Studio or VB.net? Which one are you using, because the code is fundamentally different for each!
IE... Code for running a SQL Statement in SQL is different than running the same code in Access(VBA).

So, Which program are you using? (Is this a good question NeoPa?)
Aug 24 '10 #57
32,171 Expert Mod 16PB
Michael Adams:
(Is this a good question NeoPa?)
It seems valid. Fundamentally, anything which can help communication is good. Communication in this thread is pretty poor overall. That is not to say anyone is being lazy or not trying, as some people just don't have good instincts or skills in that direction. Anything that can help members to understand the critical nature of clear communication, and how much depends on that, is a good thing in my book.

PS. From what's been posted already I'm fairly sure Access is the application involved. There seems to be some confusion over how SQL & VBA fit into the whole picture, but I'm confident that's where the issues lie.
Aug 25 '10 #58
Just for a side note then, When he is coding a SQL statement does it need to start like?
Expand|Select|Wrap|Line Numbers
  1. ssql
Aug 26 '10 #59
32,171 Expert Mod 16PB
No Michael (unless I misunderstand you completely, which is possible as I don't know where you're coming from with this).

SQL statements are usually resolved first as VBA strings, and are then passed to the SQL interpreter in one of a whole bundle of ways.

The most common form of SQL would be a simple SELECT statement of the form :
Expand|Select|Wrap|Line Numbers
  1. SELECT   [X]
  2.        , [Y]
  3.        , ...
  4. FROM     [Table]
  5. WHERE    ...
  6. ORDER BY ...
Aug 26 '10 #60
I ment in VBA. The code that I have used starts with ssql then the SELECT...
Aug 26 '10 #61
32,171 Expert Mod 16PB
I can only guess you have a string variable declared as sSQL Michael. In that case yes of course, but there's no way I can know what you use as variable names without your telling me ;)
Aug 26 '10 #62

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Mark | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.