Open one form based on another

S

SueM

Hi,

I want to open one form where details are filtered based
on data entered in the textbox of another form.

I've tried the command below, but keep getting the
debugger coming up. It looks from that like something is
wrong with the textbox name portion of this, but I can't
figure out what's wrong.

Any ideas?

Private Sub Command2_Click()
DoCmd.OpenForm "DETAILSSF"
Where [NAMESF] = [Forms]![NameSearch]![Text0NS]
End Sub

DETAILSSF = name of form to be filtered on opening
NAMESF = combobox to be filtered on detailssf form
NameSearch = form that contains the textbox which has
the data entered into it to filter from
TextoNS = textbox containing the data to filter
detailssfform from

Where am I going wrong?

Cheers,

Sue
 
S

Steve Schapel

Sue,

The syntax of your code is not correct. The OpenForm method has
provision for a Where Condition argument. Assuming that Command2 is a
button on the NameSearch form, and assuming that Text0NS is text rather
than number data type, try it like this...

Private Sub Command2_Click()
DoCmd.OpenForm "DETAILSSF", , , "[NAMESF] ='" & Me.Text0NS & "'"
End Sub
 
S

SueM

Works a treat - thanks!
-----Original Message-----
Sue,

The syntax of your code is not correct. The OpenForm method has
provision for a Where Condition argument. Assuming that Command2 is a
button on the NameSearch form, and assuming that Text0NS is text rather
than number data type, try it like this...

Private Sub Command2_Click()
DoCmd.OpenForm "DETAILSSF", , , "[NAMESF] ='" & Me.Text0NS & "'"
End Sub

--
Steve Schapel, Microsoft Access MVP
Hi,

I want to open one form where details are filtered based
on data entered in the textbox of another form.

I've tried the command below, but keep getting the
debugger coming up. It looks from that like something is
wrong with the textbox name portion of this, but I can't
figure out what's wrong.

Any ideas?

Private Sub Command2_Click()
DoCmd.OpenForm "DETAILSSF"
Where [NAMESF] = [Forms]![NameSearch]![Text0NS]
End Sub

DETAILSSF = name of form to be filtered on opening
NAMESF = combobox to be filtered on detailssf form
NameSearch = form that contains the textbox which has
the data entered into it to filter from
TextoNS = textbox containing the data to filter
detailssfform from

Where am I going wrong?

Cheers,

Sue
.
 

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

Top