Edit Combo Box

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

I have a combo box which I use to grab a list of names. I wanted to create a
button that would allow me to edit the name choosen should it be necessary.

So I created my button and wrote a simple macro... Well it doesn't want to
work for me. Heres the macro:

Action: OpenForm
Form Name: FRM_TM_Information
View: Form
Filter Name: ="[NameofPerson]=" & [NameofPerson1]
Data Mode:
Window Mode: Normal

Any help is always appreciated! Thanks
Where condition:
 
Hi Bill,
If NameofPerson1 is a text field you will need a different syntax, like this
Filter Name: ="[NameofPerson]='" & [NameofPerson1]& "'"

expanding the quotes to make it easier to read, we get
' " & [NameofPerson1]& " ' "

Other things to check:
Check the spelling is correct for form and field names.
Check that NameofPerson1 is correct for the combo.
I mean that if the combo has more than 1 column, make sure you are using the
correct column in the filter name.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
<picky>

If the name of the person includes an apostrophe (D'Arcy, O'Brien, etc.),
using a single quote will fail.

You need to use

Filter Name: ="[NameofPerson]=""" & [NameofPerson1] & """"

(that's three double quotes in a row before the first ampersand, and four
quotes in a row after the second one).

Of course, that will fail in the (granted, unlikely) event that there are
double quotes in the name (think nicknames...), in which case you need
something like

Filter Name: ="[NameofPerson]='" & Replace([NameofPerson1], "'", "''") & "'"

Exagerated for clarity, that's

Filter Name: ="[NameofPerson]= ' " & Replace([NameofPerson1], " ' ", " ' '
") & " ' "

</picky>


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jeanette Cunningham said:
Hi Bill,
If NameofPerson1 is a text field you will need a different syntax, like
this
Filter Name: ="[NameofPerson]='" & [NameofPerson1]& "'"

expanding the quotes to make it easier to read, we get
' " & [NameofPerson1]& " ' "

Other things to check:
Check the spelling is correct for form and field names.
Check that NameofPerson1 is correct for the combo.
I mean that if the combo has more than 1 column, make sure you are using
the correct column in the filter name.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Bill said:
I have a combo box which I use to grab a list of names. I wanted to
create a
button that would allow me to edit the name choosen should it be
necessary.

So I created my button and wrote a simple macro... Well it doesn't want
to
work for me. Heres the macro:

Action: OpenForm
Form Name: FRM_TM_Information
View: Form
Filter Name: ="[NameofPerson]=" & [NameofPerson1]
Data Mode:
Window Mode: Normal

Any help is always appreciated! Thanks
Where condition:
 
This worked great!!! Thank you both for your input.

Douglas J. Steele said:
<picky>

If the name of the person includes an apostrophe (D'Arcy, O'Brien, etc.),
using a single quote will fail.

You need to use

Filter Name: ="[NameofPerson]=""" & [NameofPerson1] & """"

(that's three double quotes in a row before the first ampersand, and four
quotes in a row after the second one).

Of course, that will fail in the (granted, unlikely) event that there are
double quotes in the name (think nicknames...), in which case you need
something like

Filter Name: ="[NameofPerson]='" & Replace([NameofPerson1], "'", "''") & "'"

Exagerated for clarity, that's

Filter Name: ="[NameofPerson]= ' " & Replace([NameofPerson1], " ' ", " ' '
") & " ' "

</picky>


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jeanette Cunningham said:
Hi Bill,
If NameofPerson1 is a text field you will need a different syntax, like
this
Filter Name: ="[NameofPerson]='" & [NameofPerson1]& "'"

expanding the quotes to make it easier to read, we get
' " & [NameofPerson1]& " ' "

Other things to check:
Check the spelling is correct for form and field names.
Check that NameofPerson1 is correct for the combo.
I mean that if the combo has more than 1 column, make sure you are using
the correct column in the filter name.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Bill said:
I have a combo box which I use to grab a list of names. I wanted to
create a
button that would allow me to edit the name choosen should it be
necessary.

So I created my button and wrote a simple macro... Well it doesn't want
to
work for me. Heres the macro:

Action: OpenForm
Form Name: FRM_TM_Information
View: Form
Filter Name: ="[NameofPerson]=" & [NameofPerson1]
Data Mode:
Window Mode: Normal

Any help is always appreciated! Thanks
Where condition:
 
Back
Top