[thelist] VB syntax help

Jon Haworth jhaworth at witanjardine.co.uk
Tue Jul 30 09:21:00 CDT 2002


Hi Darren,

> > Firstly, where are FirstNumber and SecondNumber coming from?
>
> names of two text boxes I'm trying to use to input the range of
> number of products I want to filter. Do I need to declare them
> beyond naming them ?
>

Nope, should be something like:

Private Sub Calculate_Phones_Click()

  Dim lngFirstNumber as Long
  Dim lngSecondNumber as Long

  lngFirstNumber = Val(Me.FirstNumber.Text)
  lngSecondNumber = Val(Me.SecondNumber.Text)

  Me.Filter = " PostcodeMain = '" & PostcodeMain & _
    "' AND NumberOfPhones >= " & lngFirstNumber & _
    " AND NumberOfPhones <= " & lngSecondNumber

  Me.FilterOn = True

End Sub


I'd also suggest building that bit of SQL in a string and displaying it,
just to check it reads OK:

  Dim strFilter as String

  strFilter = " PostcodeMain = '" & PostcodeMain & _
    "' AND NumberOfPhones >= " & lngFirstNumber & _
    " AND NumberOfPhones <= " & lngSecondNumber

  Me.Filter = strFilter
  Msgbox strFilter


Cheers
Jon



More information about the thelist mailing list