Error 2001 and DLookup

G

Guest

I am trying to use DLookup in a form to populate other fields in the form
once a selection is made. The database I'm working in was created by someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
....code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops up,
telling me I cancelled the previous operation. What am I doing wrong? These
are text fields.

Katie
 
D

Duane Hookom

Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are numbered
beginning with 0.
 
G

Guest

Those all make sense. And going forward, I will be naming new controls
descriptively. Because I'm stepping into this, I hesitate to rename controls
because there is a lot of code and I don't want to miss a reference and mess
up the functionality.

I tried the last option, adding an additional hidden column to the combo
box. And this solves the updating the Make/Model field. However, I now get
"#Name?" in the ComboBox184 when I open the form to do data entry. Any
suggestions?

If I can't make that go away, I will try reverting back to my previous code,
and putting in square brackets as you suggested in the 2nd option. (The tail
is a text type field.)

Thanks.

Duane Hookom said:
Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are numbered
beginning with 0.

--
Duane Hookom
MS Access MVP


Tech Geek 1234 said:
I am trying to use DLookup in a form to populate other fields in the form
once a selection is made. The database I'm working in was created by
someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
...code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops up,
telling me I cancelled the previous operation. What am I doing wrong?
These
are text fields.

Katie
 
D

Duane Hookom

We can't tell what's wrong with ComboBox184 without know some of its
properties:
Name:
Control Source:
Column Count:
Row Source:
Bound Column:
Column Widths:

--
Duane Hookom
MS Access MVP

Tech Geek 1234 said:
Those all make sense. And going forward, I will be naming new controls
descriptively. Because I'm stepping into this, I hesitate to rename
controls
because there is a lot of code and I don't want to miss a reference and
mess
up the functionality.

I tried the last option, adding an additional hidden column to the combo
box. And this solves the updating the Make/Model field. However, I now
get
"#Name?" in the ComboBox184 when I open the form to do data entry. Any
suggestions?

If I can't make that go away, I will try reverting back to my previous
code,
and putting in square brackets as you suggested in the 2nd option. (The
tail
is a text type field.)

Thanks.

Duane Hookom said:
Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get
fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are
numbered
beginning with 0.

--
Duane Hookom
MS Access MVP


message
I am trying to use DLookup in a form to populate other fields in the
form
once a selection is made. The database I'm working in was created by
someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
...code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing
to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops
up,
telling me I cancelled the previous operation. What am I doing wrong?
These
are text fields.

Katie
 
G

Guest

Ok, here is the info. The data I want stored in the table is TAIL, which is
a text type field.

Name: Combo184
Control Source: REG
Column Count: 2
Row Source: SELECT [Aircraft].[MAKE/MODEL], [Aircraft].[TAIL] FROM [Aircraft]
Bound Column: 2
Column Widths: 0";1"


Duane Hookom said:
We can't tell what's wrong with ComboBox184 without know some of its
properties:
Name: Combo184
Control Source: REG
Column Count: 2
Row Source: SELECT [Aircraft].[MAKE/MODEL], [Aircraft].[TAIL] FROM [Aircraft]
Bound Column: 2
Column Widths: 0";1"

--
Duane Hookom
MS Access MVP

Tech Geek 1234 said:
Those all make sense. And going forward, I will be naming new controls
descriptively. Because I'm stepping into this, I hesitate to rename
controls
because there is a lot of code and I don't want to miss a reference and
mess
up the functionality.

I tried the last option, adding an additional hidden column to the combo
box. And this solves the updating the Make/Model field. However, I now
get
"#Name?" in the ComboBox184 when I open the form to do data entry. Any
suggestions?

If I can't make that go away, I will try reverting back to my previous
code,
and putting in square brackets as you suggested in the 2nd option. (The
tail
is a text type field.)

Thanks.

Duane Hookom said:
Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get
fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are
numbered
beginning with 0.

--
Duane Hookom
MS Access MVP


message
I am trying to use DLookup in a form to populate other fields in the
form
once a selection is made. The database I'm working in was created by
someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
...code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing
to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops
up,
telling me I cancelled the previous operation. What am I doing wrong?
These
are text fields.

Katie
 
G

Guest

Actually, let me clarify. The data I want looked up is the TAIL from the
Aircraft table, and I want it stored in the REG field of my form. That is
why the Control Source is "REG"; that is the field that's storing the data.
The form is based off a table called FR.

Tech Geek 1234 said:
Ok, here is the info. The data I want stored in the table is TAIL, which is
a text type field.

Name: Combo184
Control Source: REG
Column Count: 2
Row Source: SELECT [Aircraft].[MAKE/MODEL], [Aircraft].[TAIL] FROM [Aircraft]
Bound Column: 2
Column Widths: 0";1"


Duane Hookom said:
We can't tell what's wrong with ComboBox184 without know some of its
properties:
Name: Combo184
Control Source: REG
Column Count: 2
Row Source: SELECT [Aircraft].[MAKE/MODEL], [Aircraft].[TAIL] FROM [Aircraft]
Bound Column: 2
Column Widths: 0";1"

--
Duane Hookom
MS Access MVP

Tech Geek 1234 said:
Those all make sense. And going forward, I will be naming new controls
descriptively. Because I'm stepping into this, I hesitate to rename
controls
because there is a lot of code and I don't want to miss a reference and
mess
up the functionality.

I tried the last option, adding an additional hidden column to the combo
box. And this solves the updating the Make/Model field. However, I now
get
"#Name?" in the ComboBox184 when I open the form to do data entry. Any
suggestions?

If I can't make that go away, I will try reverting back to my previous
code,
and putting in square brackets as you suggested in the 2nd option. (The
tail
is a text type field.)

Thanks.

:

Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get
fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are
numbered
beginning with 0.

--
Duane Hookom
MS Access MVP


message
I am trying to use DLookup in a form to populate other fields in the
form
once a selection is made. The database I'm working in was created by
someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
...code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing
to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops
up,
telling me I cancelled the previous operation. What am I doing wrong?
These
are text fields.

Katie
 
G

Guest

I figured it out...the guy before me had a default value for the field. So
something was wrong with that and that's why it displayed the error. I
removed it and left it blank, and it works wonderfully.

Thanks for your help!

Duane Hookom said:
We can't tell what's wrong with ComboBox184 without know some of its
properties:
Name:
Control Source:
Column Count:
Row Source:
Bound Column:
Column Widths:

--
Duane Hookom
MS Access MVP

Tech Geek 1234 said:
Those all make sense. And going forward, I will be naming new controls
descriptively. Because I'm stepping into this, I hesitate to rename
controls
because there is a lot of code and I don't want to miss a reference and
mess
up the functionality.

I tried the last option, adding an additional hidden column to the combo
box. And this solves the updating the Make/Model field. However, I now
get
"#Name?" in the ComboBox184 when I open the form to do data entry. Any
suggestions?

If I can't make that go away, I will try reverting back to my previous
code,
and putting in square brackets as you suggested in the 2nd option. (The
tail
is a text type field.)

Thanks.

Duane Hookom said:
Several possible issues.
1) Your expression is attempting to divide Make by Model. This is the
penalty for using non-standard characters in object names and can get
fixed
by changing the field name or wrapping it in [ ]s.
DLookup("[Make/Model]",...
2) Combo184 is unknown to the expression. You might try:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = " & [Combo184])
or if Tail is a text type field:
Me.MAKE = DLookup("[Make/Model]", "Aircraft", "TAIL = """ & [Combo184] &
"""")

Before you do this, you should consider changing your combo box name to
something that is self-descriptive.

If your combo box is based on the Aircraft table, then you should add the
[Make/Model] field to the Row Source and use code like:
Me.MAKE = Me.Combo184.Column(x)
where "x" is the column number of the Make/Model field. Columns are
numbered
beginning with 0.

--
Duane Hookom
MS Access MVP


message
I am trying to use DLookup in a form to populate other fields in the
form
once a selection is made. The database I'm working in was created by
someone
else and I am stepping in now to take over and add new functionality.

Private Sub Combo184_AfterUpdate()
...code here that doesn't apply...
Me.MAKE = DLookup("Make/Model", "Aircraft", "TAIL = [Combo184]")
End Sub

"Make" is the name of the text box on the form
"Make/Model" is the field name in the table "Aircraft"
"TAIL" is what I am selecting in Combo184, and is what I am referencing
to
match
up the correct record in the Aircraft table

When I select the Tail number from the Combo Box, the Error 2001 pops
up,
telling me I cancelled the previous operation. What am I doing wrong?
These
are text fields.

Katie
 

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