Search for Data in a form

K

Karen

Hello
I have a form that is being used to update data in a table called
"Customer". This table holds customer info like Businessname/address etc...
I added a combo box to the form so when someone wants to update info on any
customer they can search by "businessname" and the customer would appear in
the form for data entry to begin. My combo box properties are as follows:

Control Source- null
Row Source Type- Table/query
After update - Events procedure as follows:

Private Sub Combo70_AfterUpdate()
DoCmd.ShowAllRecords
Me!txtbusinessname.SetFocus
DoCmd.FindRecord Me!cboFindCustomer
Me!cboFindCustomer.Value = ""

End Sub

Its not working. When I selected debug on the error it highlighted the
"Me!txtbusinessname.SetFocus" line on the code above.

Can anyone help?
Thanks
 
K

Karen

Sorry.. it is

Runtime error # 2465
"MS Access can't find te field 'txtbusinessname' referred to in your
expression"

The field name is businessname so I am not sure why this error is occuring.

Thanks
 
K

Klatuu

Check your spelling both in the code and in the properties dialog for the
control. It appears they do not match.
 
K

Karen

If I am using the correct field it is spelled correctly. Question- this
field name in this code is supposed to be of what exactly on the form? Maybe
that is my problem.
 
K

Klatuu

What it is calling field name is actually a control name. It should be the
name of the control on the form. It should be Me. or Me! and the name of the
text box.
 
K

Karen

This is a combo box that I am trying to use to search for a record on a form
and auto populate the date in those fields once a selection is chosen. I.e.
Customer name - "Frank" is chosen and then address zip etc is populated for
the user to edit etc. Combo70 is the combo name. The field I am using is
called "Businessname" (customer name) should "txt" be in front of
"Businessname"?
 
K

Karen

OK, I fixed that error because I had incorrect field name. I have a new
error that I am not sure how to fix..

Runtime error# 2162
A Macro set to one of the current fields properties failed becuse of an
error in a find action argument.

this is my code
Private Sub Combo70_AfterUpdate()
DoCmd.ShowAllRecords
Me!Combo70.SetFocus
DoCmd.FindRecord Me!Combo70
Me!Combo70.Value = ""

End Sub

Can you help.
Sorry and thanks!
 

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