Query SQL Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having trouble with a fairly complex query, which can be easily defined
using SQL coding, but unfortunately I'm not all that familiar with VB...

Anyhow, I'd like to have my query check 26 individual text boxes on a form
that the user can enter values into... I've got a basic outline but have some
problems filling in the language gaps.

My best guess says I need to loop a section of code 26 times, then using an
If, Else If statement determine whether the text box in question is empty or
has an entered value, then pass that value to the appropriate search criteria
in the query. I'd also like to be able to leave the text box empty and have
the query not search that particular field.

Can this be done?

Thanks in Advance.
 
I wouldn't use the loop, just add code for each control, but you're on the
right track.

example:
if len(controlname) > 0 then
strSQL = strSQL & " AND [Fieldname] = " & controlname
end if
 
Back
Top