By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,068 Members | 1,734 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,068 IT Pros & Developers. It's quick & easy.

Manipulate current datasheet record in function invoked from macro

P: n/a
This database has no forms. I am viewing an Access table in datasheet
view. I'd like to execute a macro to execute a function (using
"runcode"). In the function, I'll reading data from the record the
cursor was on in the datasheet at the time I executed the macro.

So, the questions are: 1) In the macro, how to I get my hands on the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro, and 2) How do I pass the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro to the function invoked from
the macro?

Thanks

Oct 10 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Bill wrote:
This database has no forms. I am viewing an Access table in datasheet
view. I'd like to execute a macro to execute a function (using
"runcode"). In the function, I'll reading data from the record the
cursor was on in the datasheet at the time I executed the macro.

So, the questions are: 1) In the macro, how to I get my hands on the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro, and 2) How do I pass the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro to the function invoked from
the macro?

Thanks
Hmm...
You're not using forms but you're using macros. Create a form, drop
the primary key of the table on it, then reference the primary key on
the form in your query. Then put a button on your form to run the
query for you. Just wondering... why do you have an interfaceless
database?

Oct 10 '06 #2

P: n/a
Let me explain....

The database does have an interface - it has a form + code that
generates a list of manuals from table "A" in the database, then pulls
text from table "B" based on the manual selected from table "A" and
then uses Word automation to output the text from table "B" as a Word
document. One of the things this form code does while processing
records from table "B" and creating the Word doc is to concatenate text
from two fields from table "B" records so that it looks like a single
paragraph in the Word doc.

So, before I invoke the form and create the Word docs, I have to do
data entry into table "B". However, I do not use a form do to data
entry into the table "B". I use the Access data sheet view to do the
data entry into table "B". What I want is a preview of the two fields
concatenated together (i.e., before I actually produce the Word doc).
I want to invoke a macro which invokes a function which will
concatenate the two text fields and show them to me as the preview.
What I can't figure out is how to pass the key of the record the cursor
was on when I invoked the macro TO the macro, and then on to the
function (using the Runcode action) so I can read the record,
concatenate the text, and display it in a msgbox or something.

I have successfuly invoked a macro while in datasheeet view
(Tools->macro->run) - I just can't figure out how to pass the key of
the record the cursor was on when I invoked the macro TO the macro, and
then on to the function invoked by the macro (using the Runcode
action). Right now, the functin just throws up an empty msgbox

I guess I could create a form to show table "B" in datasheet view just
so I have a form, but that seems unnecessary if I can figure out how to
pass the recodrd key to the macro and function

Does this make sense?
pi********@hotmail.com wrote:
Bill wrote:
This database has no forms. I am viewing an Access table in datasheet
view. I'd like to execute a macro to execute a function (using
"runcode"). In the function, I'll reading data from the record the
cursor was on in the datasheet at the time I executed the macro.

So, the questions are: 1) In the macro, how to I get my hands on the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro, and 2) How do I pass the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro to the function invoked from
the macro?

Thanks

Hmm...
You're not using forms but you're using macros. Create a form, drop
the primary key of the table on it, then reference the primary key on
the form in your query. Then put a button on your form to run the
query for you. Just wondering... why do you have an interfaceless
database?
Oct 10 '06 #3

P: n/a
I kind of lied. The database does have an interface (form+code), but I
don't use it for data entry. Also, you can develop and use macros
without having created the first form, yes?

Anyway, the DB has a form + code that generates a list of manuals from
table "A" in the database, then pulls text from table "B" based on the
manual selected from table "A" and then uses Word automation to output
the text from table "B" as a Word document. One of the things this form
code does while processing records from table "B" and creating the Word
doc is to concatenate text from two fields from table "B" records so
that it looks like a single paragraph in the Word doc.

Before I invoke the form to create the Word docs, I have to do data
entry in table "B". However, I do not use a form do to data entry into
the table "B". I use the Access data sheet view to do the data entry
into table "B". What I want is a preview of the two fields
concatenated together (i.e., before I actually produce the Word doc).

I figure I can accomplish this by setting my cursor on a record (in
datasheet view), invoking a macro which uses runcode to invoke a
function. The function will pull a query to grab the record that my
cursor was on (when I invoked the macro), concatenate the two fields
and show them to me in a message box. What I can't figure out is how to
pass the key of the record the cursor. The only gotcha is that I need
to pass the key of the record that the cursor was on when the macro was
invoked TO the macro, and then on to the function.

Does this make sense?

pi********@hotmail.com wrote:
Bill wrote:
This database has no forms. I am viewing an Access table in datasheet
view. I'd like to execute a macro to execute a function (using
"runcode"). In the function, I'll reading data from the record the
cursor was on in the datasheet at the time I executed the macro.

So, the questions are: 1) In the macro, how to I get my hands on the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro, and 2) How do I pass the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro to the function invoked from
the macro?

Thanks

Hmm...
You're not using forms but you're using macros. Create a form, drop
the primary key of the table on it, then reference the primary key on
the form in your query. Then put a button on your form to run the
query for you. Just wondering... why do you have an interfaceless
database?
Oct 11 '06 #4

P: n/a
I kind of lied. The database does have an interface (form+code), but I
don't use it for data entry. Also, you can develop and use macros
without having created the first form, yes?

Anyway, the DB has a form + code that generates a list of manuals from
table "A" in the database, then pulls text from table "B" based on the
manual selected from table "A" and then uses Word automation to output
the text from table "B" as a Word document. One of the things this form
code does while processing records from table "B" and creating the Word
doc is to concatenate text from two fields from table "B" records so
that it looks like a single paragraph in the Word doc.

Before I invoke the form to create the Word docs, I have to do data
entry in table "B". However, I do not use a form do to data entry into
the table "B". I use the Access data sheet view to do the data entry
into table "B". What I want is a preview of the two fields
concatenated together (i.e., before I actually produce the Word doc).

I figure I can accomplish this by setting my cursor on a record (in
datasheet view), invoking a macro that uses runcode to invoke a
function. The function will pull a query to grab the record that my
cursor was on (when I invoked the macro), concatenate the two fields
and show them to me in a message box. What I can't figure out is how to
pass the key of the record the cursor was on when I invoked the macro.
The only gotcha is that I need to pass the key of the record that the
cursor was on when the macro was invoked TO the macro, and then on to
the function.
Does this make sense?
pi********@hotmail.com wrote:
Bill wrote:
This database has no forms. I am viewing an Access table in datasheet
view. I'd like to execute a macro to execute a function (using
"runcode"). In the function, I'll reading data from the record the
cursor was on in the datasheet at the time I executed the macro.

So, the questions are: 1) In the macro, how to I get my hands on the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro, and 2) How do I pass the
record key or record data of the record the cursor was on in the
datasheet at the time I executed the macro to the function invoked from
the macro?

Thanks

Hmm...
You're not using forms but you're using macros. Create a form, drop
the primary key of the table on it, then reference the primary key on
the form in your query. Then put a button on your form to run the
query for you. Just wondering... why do you have an interfaceless
database?
Oct 11 '06 #5

P: n/a
I would create a form that views a single record at a time, point the
query at the form to get the criteria and then pass the filtered query
to Word. But that's just me...

Oct 11 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.