Build criteria - error

G

Guest

Hi,,

i have the following code, when i run it i get a question about entrying the cbo criteria as a parameter (as in a parameter query).. anyone knows whats wrong?

Function BuildSqlString(sSQL As String) As Boolea

Dim sSelect As Strin
Dim sFrom As Strin
Dim sWhere As Strin
Dim Db As Databas

sSelect = "s.*

sFrom = "Kontrollmelding s

If Valg2 The
sWhere = sWhere & " s.Berøringspunkter = " & CboBerøringspunk
End I

If Valg1 The
sWhere = sWhere & " And s.[Tips nummer] = " & CboTipsnumme

End I
 
D

Duane Hookom

It would help to know where this code is running. If it is running in a
form, are there controls on the form CboBerøringspunkt and CboTipsnummer?
Are the fields Berøringspunkter and [Tips nummer] text or numeric?
Where and what are Valg2 and Valg1?
It doesn't look like you use sFrom. Also, if Valg2 is not true then your
sWhere will look something like " AND s. " which should not include the "
AND ".
--
Duane Hookom
MS Access MVP


Erik said:
Hi,,

i have the following code, when i run it i get a question about entrying
the cbo criteria as a parameter (as in a parameter query).. anyone knows
whats wrong?
Function BuildSqlString(sSQL As String) As Boolean

Dim sSelect As String
Dim sFrom As String
Dim sWhere As String
Dim Db As Database

sSelect = "s.* "

sFrom = "Kontrollmelding s "

If Valg2 Then
sWhere = sWhere & " s.Berøringspunkter = " & CboBerøringspunkt
End If


If Valg1 Then
sWhere = sWhere & " And s.[Tips nummer] = " & CboTipsnummer

End If
 
G

Guest

Hi,

The code i running in a form and all values included are text. Valg1 or Valg2 are to check boxes that have a primary function that is to activate (enable) the combo boxes (berøringspunkt and Tips nummer). All my code in vba refers (hopefully) to sform etc.

Erik
 
D

Duane Hookom

Function BuildSqlString(sSQL As String) As Boolean
Dim sSelect As String
Dim sFrom As String
Dim sWhere As String
Dim Db As Database

sSelect = "s.* "
sWhere = "1 = 1 "
sFrom = "Kontrollmelding s "

If Valg2 = True Then
sWhere = sWhere & " s.Berøringspunkter = """ & CboBerøringspunkt &
""" "
End If

If Valg1 = True Then
sWhere = sWhere & " And s.[Tips nummer] = """ & CboTipsnummer & """"
End If


--
Duane Hookom
MS Access MVP


Erik said:
Hi,

The code i running in a form and all values included are text. Valg1 or
Valg2 are to check boxes that have a primary function that is to activate
(enable) the combo boxes (berøringspunkt and Tips nummer). All my code in
vba refers (hopefully) to sform etc.
 

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

Similar Threads


Top