[thelist] VB syntax help

Jon Haworth jhaworth at witanjardine.co.uk
Tue Jul 30 08:18:00 CDT 2002


Hi Darren,

> Can anybody please help me with this bit of VB.
> Its not my bag and I need to get it sorted out today.

I'll give it a go...

> Private Sub Calculate_Phones_Click()
> Me.Filter = " PostcodeMain = '" & PostcodeMain & _
>   "' AND NumberOfPhones >= " &_
>   FirstNumber & " AND NumberOfPhones <= " & SecondNumber
> Me.FilterOn = True
> End Sub

Two immediate things leap to mind:

Firstly, where are FirstNumber and SecondNumber coming from? If they're
variables, you're not declaring them anywhere that I can see, and if they're
controls, you need to reference them as Me.FirstNumber and Me.SecondNumber.

Secondly, are you sure you don't have to do a Me.Refresh or Me.Requery or
something like that? I think this is less likely, but it depends on how your
form works... don't know if you can do bound and unbound controls in Access
(I haven't played with it in a while)

There are great VB lists at:
Beginners - http://peach.ease.lsoft.com/archives/visbas-beginners.html
Advanced  - http://peach.ease.lsoft.com/archives/visbas-l.html

Cheers
Jon









More information about the thelist mailing list