E
Erik
Hi, im trying to build a sql query that works through a form that allows the user to select different parameters (frmCriteria). My problem is that when i must join to tables in three of my comboboxes on frmCriteri and get an error. I thing this method by a frmCriteria is a well known method so it must be thats stupid here.. anyway.. here is the code im using in my function part of the form
Function BuildSqlString(sSQL As String) As Boolea
Dim sSelect As Strin
Dim sFrom As Strin
Dim sWhere As Strin
Dim where As Lon
Dim db As Databas
sSelect = "s.[Tips nummer] "
sFrom = "Kontrollmelding s
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
**cbo equales the combo boxes on frmCriteria and Valg# is the checkboxes used to activate the combobox.
sSQL = "SELECT " & sSelec
sSQL = sSQL & "FROM " & sFro
If sWhere <> "" Then sSQL = sSQL & "WHERE " & Mid$(sWhere, 6
BuildSqlString = Tru
End Functio
Any ideas on how to get this to work - its very important that Valg# is separate choises.. the user can chose one or more of this.
Hope someone can help me!
Thnx..
Eri
Function BuildSqlString(sSQL As String) As Boolea
Dim sSelect As Strin
Dim sFrom As Strin
Dim sWhere As Strin
Dim where As Lon
Dim db As Databas
sSelect = "s.[Tips nummer] "
sFrom = "Kontrollmelding s
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
**cbo equales the combo boxes on frmCriteria and Valg# is the checkboxes used to activate the combobox.
sSQL = "SELECT " & sSelec
sSQL = sSQL & "FROM " & sFro
If sWhere <> "" Then sSQL = sSQL & "WHERE " & Mid$(sWhere, 6
BuildSqlString = Tru
End Functio
Any ideas on how to get this to work - its very important that Valg# is separate choises.. the user can chose one or more of this.
Hope someone can help me!
Thnx..
Eri