Query Only Creent Record?

  • Thread starter Thread starter Hulk
  • Start date Start date
H

Hulk

Is there a way to put build a query to accept only the current record from
another form? I want to use the autonumber to show only the record showing
on the screen and need to build a query to pass that information into
another form.

Thanks
Bill
 
Bill

Why?

You've described "how". Perhaps the 'group readers can offer you an
alternate approach if you explain what problem you are trying to solve by
passing information to a second form...
 
I'd also like to know how to do this. I personally am creating a small
change management database. Once a change has been initiated I would like
for the developer to be able to go in review the request and then click on a
button to pull up the developer notes section which lives in a different
table.
 
Chris

Another approach to handling this would be to use a sub-form. The Request
information lives on a main form, and the related "developer notes" live on
a sub-form, tied to the main form by the ID field of the Request.
 
Jeff,
I have a table called Memos that the user enters information into only
on an add form, when they have added the information I want a query command
button so that they can e-mail only the information in the current form, no
others. I build a command button for e-mailing with sendobject but it send
the whole tabel in forms. I only want to sent the current record.
They suggested way to build a command button but it had many lines of
code and it didn't work. I have tried and tried but building a query to
show only the current record which had just been added seems like a way
around the problem. It hasn't happen. The table has an autonumber which it
uses as the ID, the query uses the information from the main table of
"memos" and with the ID as a reference I want to show that information in a
form called "current form" which will have a command button on it to e-mail
just the current form. I can't make it to simple, and code just doesn't
seem to work, I'm just a novice.

Thanks
Bill
 
Bill

I'm a bit unclear still...

Your description said, roughly, "it didn't work". That isn't much to go on
in helping you troubleshoot.

You have a table that has multiple rows. You want a way to send what you
are calling the "current record", apparently based on what is being
displayed in a form.

I would approach this by building a query that refers to that form's record
ID and returns the field(s) I wanted. Then I'd build a command button that
attached the output of that query to the outgoing email.

For the query, I'd open up the form and select a record, then use the
database window to create a new query. I'd select the RecordID field and
?some other field. Under the RecordID field, in the criterion, I'd add
something like:
Forms!YourFormName!YourRecordIDField
(your syntax may vary). Then I'd run it, to see if the query works.

For the command button, it sounds like you've already set up one that works,
just takes the whole table. What happens if you build the query above and
then send the query?

You don't mention where the command button is located, but your earlier post
mentioned two forms. I hope the command button is on the form from which
you wish to send the record.
 
Jeff,
Tried that in the criteria field but it comes up asking for the ID
number to send to E-Mail.
I may be making more of this then needed, I have five forms: Memos Add,
Memos Active, Orders Active, Memos Completed and Orders Completed. These
are all controlled from a main switchboard, the forms are all the same
except some fields are locked on each and some are not so that data entry by
the user is limited.
On each form there is a commandd button to exit back to the main
switchboard or to print the current viewed form to a printer. This command
button sends the report called Memos to a printer with just the current
record showing. These buttons work great. The problem is that when I try
to put a button on any form to E-Mail just the current form using a Macro
called Send E-Mail, it sends all the records in the table, ie 26 pages of
reports, to e-mail. I only want to sent the current record that was either
just added or that are currently still open and not completed.
I tried to build a form called Current Form and a report called Current
Mermo with a query that only calls up the current record that is showing and
then have the command button on the Current Form to E-mail just that form
with the Send E-mail Macro, but it doesn't update until the Memo Add form is
closed and so it sends a blank report. I really don't need all the extra
forms, reports and macros but I can't get the Send E-mail to send only the
current form.
I tried using the formula you gave me, but it asks for a ID to send and
even then it won't send the current form if you haven't closed the Memos Add
form.

Hope this explains the problem some, any help or questions??

Thank
Bill
 
If you build the query that refers to the form's RecordID value, does it
work? If THAT is what you are saying "asks for an ID", it could be because
the form wasn't opened and a record selected.

Build the query. Open the form. Select a record on the form. Use F11 to
go back to the database window. Find the query and try running it. What
happens?

One thing at a time...

Jeff Boyce
<Access MVP>
 
Jeff,
Running the query from the form does not work, it asks for the id number
to display, when it doesn't ask it send just a blank form instead of a form
with data in the fields. I have " [Forms]![Memos Add]![ID]" in the criteria
section of the ID. When I enter anything into the first field on click it
is to save the record and thus assigning a ID number. When I click on the
Send E-Mail Button I want it to send E-mail of only the record which you
have been working on and has been saved when leaving the first field. The
record is saved to the table when you exit the first field ok, the macro on
the form calls up the report whos name ic "Current Memo" who has the data
source of the Current Query with the above information.
Right now it is sending a blank when it doesn't ask for an ID number,
when it does ask, if you type a valid number in it is sending just that
report, which would be right. I don't want to have the user type anything
in, I want to have the command button do the sending that is why I say I may
be going about this all wrong or in a round about way.
Does that Help??
The whole file right now is only 1M, I could send it to anyone willing to
help.

Thanks
Bill Frederick
 
Bill

(see in-line comments)

Hulk said:
Jeff,
Running the query from the form does not work, it asks for the id number
to display, when it doesn't ask it send just a blank form instead of a form
with data in the fields.

Whoa! Sometimes the query prompts for ID and sometimes it doesn't? Since
the query is being changed each time, this implies that sometimes the ID is
available and sometime it isn't. What more can you figure out about when it
works and when it doesn't.

What about my earlier posted suggestion that you open your form and select
your record, then, without closing the form, you go to the query and run it?
What happens when you do that?

I have " [Forms]![Memos Add]![ID]" in the criteria
section of the ID.

I assume you mean "in the criteria section of the query"?
When I enter anything into the first field on click it
is to save the record and thus assigning a ID number.

"it is to save the record" -- how? what's your code? Have you confirmed
that a record is actually saved before proceeding? Have you confirmed that
an "ID" is actually assigned?
When I click on the
Send E-Mail Button I want it to send E-mail of only the record which you
have been working on and has been saved when leaving the first field.

You mentioned this in earlier posts, right? This is repeat, not new,
information, correct?
The
record is saved to the table when you exit the first field ok, the macro on
the form calls up the report whos name ic "Current Memo" who has the data
source of the Current Query with the above information.

What happens if you change to design mode for the report, open the
Properties window, follow the source to the query, and run the query?
Right now it is sending a blank when it doesn't ask for an ID number,
when it does ask, if you type a valid number in it is sending just that
report, which would be right.

The implication of this is that your query is not seeing the control you
believe holds the "ID". This could be because the form is closed, or
because there is a typo somewhere in how the control is being referred to.
The fact that sometimes it works (even if it sends no record) and sometimes
not still implies that the form is open sometimes, and sometimes not.
I don't want to have the user type anything
in, I want to have the command button do the sending that is why I say I may
be going about this all wrong or in a round about way.

This is a reasonable desire and the way that Access does, in fact, work.
That your combination isn't working yet suggests that it needs a bit more
troubleshooting. Don't give up!
Does that Help??
The whole file right now is only 1M, I could send it to anyone willing to
help.

You may find few takers. Would you accept and open a file from someone you
don't know?
 
Jeff,
I had the command button on all the forms, on the add memos forms it
sends a blank e-mail report. I have it set to update once the first field
is entered but it still sends a blank report.
On any other form, (of which there are four), the command button
references the same macro "Send E-Mail" which is to open the "Current
Report" which has its data set to "Current Query" which is where I am making
the changes to the criteria. I would be satisfied to send the e-mail from
only the "Add Memos" form but when I enter anything the table is updated but
when I press the command button to E-mail it still sends a blank report even
thou it is only one, it is blank.
I have removed all the command buttons from the other forms and now only
want to send from the "Add Memos" form which is for adding data only.

Thanks
Bill
Jeff Boyce said:
Bill

(see in-line comments)

Hulk said:
Jeff,
Running the query from the form does not work, it asks for the id number
to display, when it doesn't ask it send just a blank form instead of a form
with data in the fields.

Whoa! Sometimes the query prompts for ID and sometimes it doesn't? Since
the query is being changed each time, this implies that sometimes the ID
is
available and sometime it isn't. What more can you figure out about when
it
works and when it doesn't.

What about my earlier posted suggestion that you open your form and select
your record, then, without closing the form, you go to the query and run
it?
What happens when you do that?

I have " [Forms]![Memos Add]![ID]" in the criteria
section of the ID.

I assume you mean "in the criteria section of the query"?
When I enter anything into the first field on click it
is to save the record and thus assigning a ID number.

"it is to save the record" -- how? what's your code? Have you confirmed
that a record is actually saved before proceeding? Have you confirmed
that
an "ID" is actually assigned?
When I click on the
Send E-Mail Button I want it to send E-mail of only the record which you
have been working on and has been saved when leaving the first field.

You mentioned this in earlier posts, right? This is repeat, not new,
information, correct?
The
record is saved to the table when you exit the first field ok, the macro on
the form calls up the report whos name ic "Current Memo" who has the data
source of the Current Query with the above information.

What happens if you change to design mode for the report, open the
Properties window, follow the source to the query, and run the query?
Right now it is sending a blank when it doesn't ask for an ID
number,
when it does ask, if you type a valid number in it is sending just that
report, which would be right.

The implication of this is that your query is not seeing the control you
believe holds the "ID". This could be because the form is closed, or
because there is a typo somewhere in how the control is being referred to.
The fact that sometimes it works (even if it sends no record) and
sometimes
not still implies that the form is open sometimes, and sometimes not.
I don't want to have the user type anything
in, I want to have the command button do the sending that is why I say I may
be going about this all wrong or in a round about way.

This is a reasonable desire and the way that Access does, in fact, work.
That your combination isn't working yet suggests that it needs a bit more
troubleshooting. Don't give up!
Does that Help??
The whole file right now is only 1M, I could send it to anyone willing to
help.

You may find few takers. Would you accept and open a file from someone
you
don't know?
Thanks
Bill Frederick

--
Good luck

Jeff Boyce
<Access MVP>
 
Back
Top