Open one form based on another

  • Thread starter Thread starter SueM
  • Start date Start date
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
 
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
 
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
.
 
Back
Top