Search Problem

W

weircolin

Hi

I created a database last year and I am now attempting to do another
one. I got help before with a Surname Search on a form which worked
fine, I have tried to copy this over to my new database and it
searches through the names, but when I select one I get the following
error

Runtime Error '2448'

You can't assign a value to this object.

When I debug, the first line of the following code is highlighted
(indicated with **)


Private Sub cboMoveTo_AfterUpdate()

** Me.Filter = "Last Name= """ & Me.cboMoveTo & """"
Me.FilterOn = True

End Sub

Can anyone shing any light onto this?

Cheers

Colin
 
O

OldPro

Hi

I created a database last year and I am now attempting to do another
one. I got help before with a Surname Search on a form which worked
fine, I have tried to copy this over to my new database and it
searches through the names, but when I select one I get the following
error

Runtime Error '2448'

You can't assign a value to this object.

When I debug, the first line of the following code is highlighted
(indicated with **)

Private Sub cboMoveTo_AfterUpdate()

** Me.Filter = "Last Name= """ & Me.cboMoveTo & """"
Me.FilterOn = True

End Sub

Can anyone shing any light onto this?

Cheers

Colin

Make sure that Me.FilterOn=False before you try to change the .Filter
property.
 
A

AccessVandal via AccessMonster.com

Hi,

Try the "Me.FilterOn = True" first before you filter the form.

Me.FilterOn = True
Me.Filter = "Last Name= """ & Me.cboMoveTo & """"
 
W

weircolin

Hi

That helped, then it was saying I had a missing opperator in the
expression. I changed the field in the table to LastName and then
also in the code and it works fine now.

Thanks again.

Have noticed however that if I do a search for instance, for Brown,
and I get 6 names on the drop down, if I select any of them, it always
goes to the first field with that name, is there anything I can do
which will make it if I select one it shows that record?

Cheers

Colin
 
O

OldPro

Hi

That helped, then it was saying I had a missing opperator in the
expression. I changed the field in the table to LastName and then
also in the code and it works fine now.

Thanks again.

Have noticed however that if I do a search for instance, for Brown,
and I get 6 names on the drop down, if I select any of them, it always
goes to the first field with that name, is there anything I can do
which will make it if I select one it shows that record?

Cheers

Colin

There has to be a field that is different for each record, like an ID
field. It doesn't have to show on the screen, but must be part of the
rowsource. In the properties of the combobox, change the columnwidth
property show a zero for the first item (the record ID), and for the
boundcolumn property put 1.
 
A

AccessVandal via AccessMonster.com

Hi,

I did not check the quotes in your criteria as I had assumed you know what to
do. You had actually one more double quote on the left side and one on the
rigth.

If you are refering to the combo box now, as you found out that there was
more than one "Brown". You need to bound the combo box to the correct field.
What's are the fields?

Assuming "CustomerID", "LastName" are the only fields the combo box, and the
data is like...

CustomerID LastName
00001 Brown
00002 Brown
00003 so on..........

And assume the the combo is bound to the first field "CustomerID" = 1 (the
bound column property).

You'll also need to change your criteria to...

Me.Filter = "CustomerID= ' " & Me.cboMoveTo & " ' "

Note: I type a space between the quotes. And note the single quotes and again,
I assume the the "CustomerID" is Text. Remove the quotes if it is Number.
 
W

weircolin

Hi

Sorry just getting back to you, been off for a while.

I have tried to do what you said but going wrong somewhere.
Understand where the problem is and so have added a field called "ID"
which has an AutoNumber value.

I have the following

Me.FilterOn = True
Me.Filter = ID = "" & Me.cboMoveTo & ""

When I run this is shows as though it is a new field, so there is
nothing on it.

Not sure where I;m going wrong, hope someone can help.

Thanks

Colin
 
A

AccessVandal via AccessMonster.com

Hi,

Refer to my previous post.

Remove the quotes as the ID field is a number.

Me.Filter = "ID = " & Me.cboMoveTo
 

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