multi query

E

Erik

Hi,

im using a form with comboboxes to build a sql query, i have three choises (see code below) which depens on a inner join. Is this possible, i get error when i chose more than one of these (se below)..

If Valg1 = True The
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]
sWhere = " And i.[Registrert MVA] = " & CboMV
End I
If Valg2 = True The
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]
sWhere = " And i.[Levert selvangivelse og NO] = " & CboSAN
End I

If Valg5 = True The
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]
sWhere = " And i.[Betydelige restanser] = " & CboRestanse
End I

Erik
 
J

John Vinson

Hi,

im using a form with comboboxes to build a sql query, i have three choises (see code below) which depens on a inner join. Is this possible, i get error when i chose more than one of these (se below)..

If Valg1 = True Then
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]"
sWhere = " And i.[Registrert MVA] = " & CboMVA
End If
If Valg2 = True Then
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]"
sWhere = " And i.[Levert selvangivelse og NO] = " & CboSANO
End If

If Valg5 = True Then
sFrom = sFrom & " Inner Join Selskap i " & " ON s.[organisasjonsnummer] = i.[organisasjonsnummer]"
sWhere = " And i.[Betydelige restanser] = " & CboRestanser
End If

Erik

What are you then doing with sFrom and sWhere? Since the value of
sFrom apparently does not depend on the combo box at all, should it
perhaps be defined outside the IF statements? The sWhere clause should
NOT be part of the INNER JOIN syntax, but rather of a WHERE clause;
and this clause will need to start with something other than the word
AND...

Could you post some more of the context of the code here, and perhaps
the error that you're getting?
 

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