Query SQL Code

C

Chris

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.
 
M

[MVP] S.Clark

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top