Please Help!!!!!

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hey, my names Paul and I am stuck with the following
situation. Any help would be greatly appreciated.

A week ago I wrote the following:
----------------
OK. I need a macro, I think, when I click on it on a form
from a button I want it to run a query and transfer data
from one field of the query to my form. How is this
possible.
----------------

Then I got the following reply which was useful:

----------------
Hi,

I am assuming you want the data returned based on
something entered into the form. Try the following:

Open form in design mode. Click properties of field that
is being filled in on form. Click on lost focus.

Fill the following in:

Forms![field_to_fill_in]=DLookup
("[returned_field_from_table ]", "Table_name", "[Table_fie
l
d_to_match] =" & Forms![Form_name]!form_entered_field)

field_to_fill_in <-- field on your form that you are
populating from the search.
returned_field_from_table <-- the data just retrieved
Table_name <-- table being searched
Table_field_to_match <-- field in table that links to
field_to_fill_in
Form_entered_field <-- field on form that was typed into

Hope this helps you.
----------------

I am, however getting an error message. I used this
command which I typed up in the VB editor

----------------
Forms![heat/stageID]=DLookup("[Heat/StageID]", "
Heat/Stage Table", "[ Heat/StageID] =" & Forms![Results
Table]! Competitor1)
----------------

I am using this command triggering it with a command
button. The button is on the form 'Results Table'. I want
the command to go to the 'heat/stage table', look up a
record according to the 'heat/stageID' on the
form 'Results Table', find the ID in the 'heat/stageID'
on the table 'heat/stage table' and find the entrant 1
name, then copy it over to the form 'Results Table'.

Any help will be greatly appreciated.

Thanks Paul
 
Paul said:
Hey, my names Paul and I am stuck with the following
situation. Any help would be greatly appreciated.

A week ago I wrote the following:
----------------
OK. I need a macro, I think, when I click on it on a form
from a button I want it to run a query and transfer data
from one field of the query to my form. How is this
possible.
----------------

Then I got the following reply which was useful:

----------------
Hi,

I am assuming you want the data returned based on
something entered into the form. Try the following:

Open form in design mode. Click properties of field that
is being filled in on form. Click on lost focus.

Fill the following in:

Forms![field_to_fill_in]=DLookup
("[returned_field_from_table ]", "Table_name", "[Table_fie
l
d_to_match] =" & Forms![Form_name]!form_entered_field)

field_to_fill_in <-- field on your form that you are
populating from the search.
returned_field_from_table <-- the data just retrieved
Table_name <-- table being searched
Table_field_to_match <-- field in table that links to
field_to_fill_in
Form_entered_field <-- field on form that was typed into

Hope this helps you.
----------------

I am, however getting an error message. I used this
command which I typed up in the VB editor

----------------
Forms![heat/stageID]=DLookup("[Heat/StageID]", "
Heat/Stage Table", "[ Heat/StageID] =" & Forms![Results
Table]! Competitor1)
----------------

I am using this command triggering it with a command
button. The button is on the form 'Results Table'. I want
the command to go to the 'heat/stage table', look up a
record according to the 'heat/stageID' on the
form 'Results Table', find the ID in the 'heat/stageID'
on the table 'heat/stage table' and find the entrant 1
name, then copy it over to the form 'Results Table'.

Any help will be greatly appreciated.

Thanks Paul

I think I can help, but first a couple of notes on effective posting.
You'll get much better results if your subject line summarizes the
problem or the question you want the answer to. Most people who post
initial messages in these newsgroupsw want help, so a subject line of
"Help!" doesn't convey anything useful to people who may be scanning the
newsgroup and trying to decide what messages to read. Also, if you
already posted a question and got an answer, any followup question would
be better posted as a direct reply to that answer, so that it stays in
the same discussion thread, rather than beginning a new thread. I think
most people keep an eye on the threads they've been participating in, to
see if any new messages or followup questions appear. By starting a new
thread, you make it much less likely that the person who originally
responded will see your followup question, so that person can't set you
straight or correct errors in his original reply. Normally it only
nakes sense to start a new thread if, after a couple of days, there's
been no useful reply to your original question or followup questions in
that same thread.

As for your specific problem, it looks to me like your original
responsent made a small mistake and left out one qualifier for the form
reference in the example he gave you. Also, from your description it
looks like your version has the lookup backward. I *think* you want to
look up the Competitor1 field that has the matching [Heat/Stage ID], but
your code is trying to look up the [Heat/Stage ID] itself. Try this in
place of what you've got now:

Forms![Results Table]![Competitor1] = _
DLookup("Competitor1", "Heat/Stage Table", _
"[Heat/StageID] =" & Forms![Results Table]![Heat/StageID])

If that works, then you should be able to simplify it -- since the code
is running on the same form as the control being referenced -- to just
this:

Me![Competitor1] = _
DLookup("Competitor1", "Heat/Stage Table", _
"[Heat/StageID] =" & Me![Heat/StageID])
 
Back
Top