DLOOKUP DIDN'T work

O

OBWAN

How could I show field data from a child table where
childtable.autoID equals maintable.autoID on the main form?

In other words, if the user is on the main form, but wants
a textbox on the mainform with data from a child table
that is usually accessed from a subform. The
controlsource is not in the underlying table.


DLOOKUP did not work, though I got no erros when I tried
it.
 
M

Marshall Barton

OBWAN said:
How could I show field data from a child table where
childtable.autoID equals maintable.autoID on the main form?

In other words, if the user is on the main form, but wants
a textbox on the mainform with data from a child table
that is usually accessed from a subform. The
controlsource is not in the underlying table.


DLOOKUP did not work, though I got no erros when I tried
it.


DLookup should work, what did you use?

Assuming that autoID is a numeric type field, a text box
with the expression should wok:
=DLookup("field", "childtable", "autoID=" & Me.txtxautoID)

Where you have to replace field with the name of the field
you want to look up in the childtable amd txtxautoID with
the name of the main form text box that is bound to the
maintable field autoID.
 
O

OBWAN

I must be doing something wrong

I get an error:

THE OBJECT DOESN'T CONTAIN THE AUTOMATION OBJECT 'Me.'

What's happening Functionally:

If I bring up the subform and select data and then check
the table, the selection is placed into the table, no
problem.

If I click on the Mainform_combobox no selection is made,
the combobox doesnot fold-up, it just hangs open.

If I then try to click on commandbutton_open_subform
I get run time error 2447 - invalid use of the .(dot) or !
operator or invalid parenthesis, and I never got that
error until I used Dlookup as the control source.

Private sub Mainform_combobox_lostfocus()
CurrentDb.Execute "update childtable Set childfield ='"
& Me.mainform_combobox & "'Where ID=" & Me.ID

End sub
 
M

Marshall Barton

I feel completely lost here. I'm getting the idea that you
have a lot more going on than I'm aware of. I've never
heard of a combo box that drops down and then just sits
there.

How did we get from a DLookup question to one about
executing an UPdate query???

The use of a command button to "open" a subform is a foreign
concept to me and I have no idea what you're talking about
with that???

I think you need to step through the code a line at a time
to make sure that each step works as expected? Does the
DLookup work by itself if you use it in your code or the
immediate/debug window?
 
O

OBWAN

First, I appreciate you sticking with me on this...thanks.

I've never heard of a combo box that drops down and then
just sits there.

Please understand I don't want this result, I don't want
it to just sit there.

The use of a command button to "open" a subform is a
foreign concept to me and I have no idea what you're
talking about with that???

I have a command button whose purpose is to make a subform
..visible property = true , thus, in effective to the
user, "opens" the subform.............sorry for my
vernacular, it is quite user/laymen.

Another "command button" "HIDE" sets .visible = false

Does the DLookup work by itself if you use it in your
code or the >immediate/debug window?

The Dlookup is in the control source property line of the
properties "screen" in mainform_combobox


maybe we could focus on why and when this message occurs.
 
M

Marshall Barton

OBWAN said:
First, I appreciate you sticking with me on this...thanks.


just sits there.

Please understand I don't want this result, I don't want
it to just sit there.


foreign concept to me and I have no idea what you're
talking about with that???

I have a command button whose purpose is to make a subform
.visible property = true , thus, in effective to the
user, "opens" the subform.............sorry for my
vernacular, it is quite user/laymen.

Another "command button" "HIDE" sets .visible = false


code or the >immediate/debug window?

The Dlookup is in the control source property line of the
properties "screen" in mainform_combobox

Ok, I think I'm getting the picture now.

All this confusion over my mistake, sorry but I was thinking
the DLookup was in a VBA procedure even while I made it a
control source expression, aaarrgghhh!

Control source expressions do not understand Me.
Try this instead:

=DLookup("field", "childtable", "autoID=" & txtxautoID)
--
Marsh
MVP [MS Access]


 

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