Subform problem

  • Thread starter Thread starter Home
  • Start date Start date
H

Home

Hi,

i want to create a subform on a form, in which i can enter a parameter. I
have done this lots of times in a normal form and this works perfect, in the
subform it seems not to work. I have a textbox txtZoek in witch i type a
value. If the value is null then all my record mus be displayed when not
null only the values must display where Naam is like the value entered in
txtZoek. Why doesn't this work?

Thanks!

Rogier

[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null
Or
([Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![Naam] & "*")
 
Rogier,

It looks like you might have got your controls back to front in the
expression. Shouldn't it be...
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null
Or
([Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![Naam] Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] & "*")

- Steve Schapel, Microsoft Access MVP
 
Steve,

thanks for your reply. You are absolutely right about the expression.
Unfortunately, my problem remains. When i give a requery of the subform
after inserting text in my txtZoek textbox two things seem to happen:
if i type a searchstring which is a part of the first record, all my records
are displayed as a result, even if the next records does not contain this
string.
if i type a searchstring which is a part of any other record, the result is
null.

Any idea what this is?

Rogier

Steve Schapel said:
Rogier,

It looks like you might have got your controls back to front in the
expression. Shouldn't it be...
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null
Or
([Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![Naam] Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] & "*")

- Steve Schapel, Microsoft Access MVP


Hi,

i want to create a subform on a form, in which i can enter a parameter. I
have done this lots of times in a normal form and this works perfect, in the
subform it seems not to work. I have a textbox txtZoek in witch i type a
value. If the value is null then all my record mus be displayed when not
null only the values must display where Naam is like the value entered in
txtZoek. Why doesn't this work?

Thanks!

Rogier

[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null
Or
([Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![Naam] & "*")
 
Rogier,

Where is txtZoek? Is it an unbound textbox on the subform? Where is
the expression which we have been discussing? Are you using this in
VBA filtering code, or are you trying to put it in a query, or what?
What are the details of the macro or event procedure that you are
using to try to show you the required data? I can't really figure
out what you are doing.

- Steve Schapel, Microsoft Access MVP
 
Steve,

txtZoek is an unbound textbox on my subform. The expression is in the query
wich is the record source of this subform. As this is the record source i
can put the fields on my form without event procedures (at least this was
possible until i tried the same in this subform). That's what's so weird,
i've done this many times in a 'normal' form and this never caused any
problems.In fact, it's a very fast way to 'filter' data with a lot of
different expressions. I'm doing exactely the same in this subform and here
it doesn't work.

Thanks for your help!

Rogier
 
Rogier,

I must be missing something... I can't quite see how you can have this
expression in your query. Anyway, try it like this... Go to the
design view of the query, and in the criteria of the Naam field, put:

Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] & "*" Or
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null

(all in one line - note that after you save the query, Access will
probably re-organise it to suit it's own purposes... don't worry about
this).

- Steve Schapel, Microsoft Access MVP
 
Steve,

i've been busy the last few days, so i have not been abe to continue on my
form/subform problem. As i tried it again this afternoon, suddenly it works!
I don't know what i did change to make it work, but i guess it was something
small and stupid....

Thanks for all your help!

Rogier

Steve Schapel said:
Rogier,

I must be missing something... I can't quite see how you can have this
expression in your query. Anyway, try it like this... Go to the
design view of the query, and in the criteria of the Naam field, put:

Like "*" &
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] & "*" Or
[Forms]![frmKlantBestel]![subKlantZoekOp].[Form]![txtZoek] Is Null

(all in one line - note that after you save the query, Access will
probably re-organise it to suit it's own purposes... don't worry about
this).

- Steve Schapel, Microsoft Access MVP


Steve,

txtZoek is an unbound textbox on my subform. The expression is in the query
wich is the record source of this subform. As this is the record source i
can put the fields on my form without event procedures (at least this was
possible until i tried the same in this subform). That's what's so weird,
i've done this many times in a 'normal' form and this never caused any
problems.In fact, it's a very fast way to 'filter' data with a lot of
different expressions. I'm doing exactely the same in this subform and here
it doesn't work.

Thanks for your help!

Rogier
 
Back
Top