[thelist] VB syntax help

dn at dittodesign.co.uk dn at dittodesign.co.uk
Tue Jul 30 09:43:00 CDT 2002


Jon,

I get an error -

You can't reference the property or method for a control unless
the control has the focus.

in debug this line is highlighted.

  lngFirstNumber = Val(Me.FirstNumber.Text)

how do I set focus ? I take it I would need to do it on click
of the button ?


regards,

Darren Yates

who's starting to see a light and the end of this DB tunnel

dn at dittodesign.co.uk
http://dittodesign.co.uk
0161 281 1190


----- Original Message -----
From: "Jon Haworth" <jhaworth at witanjardine.co.uk>
To: <thelist at lists.evolt.org>
Sent: Tuesday, July 30, 2002 3:08 PM
Subject: RE: [thelist] VB syntax help


> 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
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
>




More information about the thelist mailing list