What am I doing wrong

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a combo box to create a search field in a form. The data below
works on every other form but I keep getting an error on a new form. The only
difference between this text and the one that works is the word project is
replaced with company. The company one works perfect (so does the one for
employees) but I can't get this to work right. The debugger always highlights
the Me!ProjectName.SetFocus line. HELP!!!

Private Sub cboFindProject_AfterUpdate()
'Moves to the Project Name text box and
'finds the record of whatever Name is selected in the combo box

DoCmd.ShowAllRecords
Me!ProjectName.SetFocus
DoCmd.FindRecord Me!cboFindProject
'Set value of combo box equal to an empty string

Me!cboFindProject.Value = ""
End Sub
 
Lori,

All I can think of is that you do not have a control on the form named
ProjectName. There may be a control which is bound to the ProjectName
field in the form's underlying table/query, but the name of the control
itself may be different. Your code should use the name of the control.
Otherwise, perhaps the ProjectName control has its Enabled property
set to No, or its Visible property set to No.

By the way, I would recommend changing this:
Me!cboFindProject.Value = ""
.... to this:
Me!cboFindProject = Null
 
I double checked, the controls for the ProjectName fields are both set to no
for the Endable and the Visible. The table shows the field as "ProjectName"
which is how its showing in the control on the form itself. Any other ideas?
 
I double checked, the controls for the ProjectName fields are both set to no
for the Endable and the Visible. The table shows the field as "ProjectName"
which is how its showing in the control on the form itself. Any other ideas?

Lori,
Forgive me for jumping in.

It's not clear (at least to me) from your response on this message
that you understand Steve's message.
We understand that the control is bound to the ProjectName field in
the table (It's control source property is ProjectName).
It is the control's NAME that Steve was questioning.
Select the control. Show it's properties. Click on the Other tab.
Name is the first property on this tab.
It should read
ProjectName
If it reads anything else, change your code to:
Me!TheControlNAME.SetFocus

Also not clear is what the control's Enabled property is.
It should be Yes (your above reply indicates it is No).
It's Visible property must also be Yes.

You cannot set focus to a control that is not Visible, or Not Enabled.
 
I understood what Steve was saying. The settings are both set for Visible YES
and Enable YES. In both the combo box and in the Control source. I've
compared these settings to other combo search boxes I've created on other
forms and they are identical, the other boxes work that's why I'm so stumped.
I've tried deleting it and starting over, copy from other forms, but nothing
seems to help.
 
Lori,

We're still not being absolutely precise here.

Can you please have a look at the Properties for what you are referring
to as the ProjectName textbox. I appreciate that the Control Source
property apparently is set to ProjectName, that's lovely. How about the
'Name' property of the textbox? What does it say there for the Name
property? Is the Name property set to ProjectName, or is it something
else? It will be good to check this before moving on to anything else.
Thanks.
 
The name of the actual field is ProjectName, the caption for the field is
Project Name with a space (appearance purposes on the form).
 
There were two different names for the field, I made the correction so that
both were the same and it worked perfectly.
 
Back
Top