Datasheet coding

S

Sandy

Hi
I have a subform that contains a datasheet of imported Excel Data. When a
user selects a column, I want to store the name of the selected column/field
in a variable. Is this possible or if not, how else could I achieve this.
The purpose is to allow users to import a spreadsheet of data into a temp
table and then select the columns of data they would like to store
permenantly.

Thanks in advance
Sandy
 
A

Arvin Meyer [MVP]

They will need to build a query to do that. An Append query, or if the
columns will change, a Make-Table query are the query types that you will
need to teach them to make. There are no events for Associated (attached)
labels. Attached labels are the ones which will show in a datasheet column
header. If there is no attached label, the field name is used for a label on
a datasheet.
 
S

Sandy

Hi Arvin
Thanks for the reply. Not sure whether I am misinterpreting your answer or
you haven't understood my question. Can I just clarify what I'm doing.

My users have a list box filled with Excel file names that are in a specific
folder on the computer. When they select one of these docs, the entire
spreadsheet is imported into an Access table called tblTempData. The field
names in this table are Field1,Field2,Field3 etc.
I have this part working.

On the form they are using is a subform/datasheet with the new imported data
displayed. When a user highlights a column (eg Field1) I would like to
store 'Field1' into a variable. All I need to know is the name of the column
they have highlighted. Is this possible?

I did read on a newsgroup thread that the process may be achieved by setting
the variable in the GotFocus event. I haven't actually tried this yet but
wondered if this is the only way to achieve the above. My database is an
..mde file.

Thanks
Sandy
 
F

fredg

Hi Arvin
Thanks for the reply. Not sure whether I am misinterpreting your answer or
you haven't understood my question. Can I just clarify what I'm doing.

My users have a list box filled with Excel file names that are in a specific
folder on the computer. When they select one of these docs, the entire
spreadsheet is imported into an Access table called tblTempData. The field
names in this table are Field1,Field2,Field3 etc.
I have this part working.

On the form they are using is a subform/datasheet with the new imported data
displayed. When a user highlights a column (eg Field1) I would like to
store 'Field1' into a variable. All I need to know is the name of the column
they have highlighted. Is this possible?

I did read on a newsgroup thread that the process may be achieved by setting
the variable in the GotFocus event. I haven't actually tried this yet but
wondered if this is the only way to achieve the above. My database is an
.mde file.

Thanks
Sandy

Not by highlighting th entire row.

If all you need is the name of the column, code EACH Field control's
Enter event:

MyVariable = Me.ActiveControl.Name


But first....
Declare MyVariable up in the code window's General Declarations
section so that it is available in all of this form's events.

Option Compare Database
Option Explicit
Dim MyVariable as String

MyVariable will be whatever field the cursor has last been (or
currently is) in.
 

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