Adding an Attachment via VBA

D

David

I'm trying to figure out a way to attach a file to a attachment feild in
Access 2007.

Basically, the file would be located in My Documents and always be called
AccuData.txt

I assume this would require some sort dao commands, which are a little out
of my league.

Any help would be great

Thank You
 
D

Damon Heron

No coding required, if all you want is a file that can be displayed on a
form that you can dbl-click on to open.
Create a table with one field - OLEObject. Save then open the table and
right click to create from file. Browse to your file and slect.
Save table.
On your form, Put an OLE Object and set the control source to your table
field. Dbl-click to open the text file.
If the form is bound to another table, then you will need to amend the
Record Source of the table by clicking on the [....] at the right of the
property field and create a query by adding your OLE table to the form's
table.

Damon
 
D

Damon Heron

I meant
"No coding required, if all you want is a file that can be displayed by
dbl-clicking on an object on a
form."

Damon Heron said:
No coding required, if all you want is a file that can be displayed on a
form that you can dbl-click on to open.
Create a table with one field - OLEObject. Save then open the table and
right click to create from file. Browse to your file and slect.
Save table.
On your form, Put an OLE Object and set the control source to your table
field. Dbl-click to open the text file.
If the form is bound to another table, then you will need to amend the
Record Source of the table by clicking on the [....] at the right of the
property field and create a query by adding your OLE table to the form's
table.

Damon

David said:
I'm trying to figure out a way to attach a file to a attachment feild in
Access 2007.

Basically, the file would be located in My Documents and always be called
AccuData.txt

I assume this would require some sort dao commands, which are a little
out
of my league.

Any help would be great

Thank You
 
D

David

Actually, this process would be part of a command button on another part of
the form. So, it would need to be code since the user would not be clicking
on the actual attachment field.

Hope this makes sense

Thank you for your previous suggestions.
David


Damon Heron said:
I meant
"No coding required, if all you want is a file that can be displayed by
dbl-clicking on an object on a
form."

Damon Heron said:
No coding required, if all you want is a file that can be displayed on a
form that you can dbl-click on to open.
Create a table with one field - OLEObject. Save then open the table and
right click to create from file. Browse to your file and slect.
Save table.
On your form, Put an OLE Object and set the control source to your table
field. Dbl-click to open the text file.
If the form is bound to another table, then you will need to amend the
Record Source of the table by clicking on the [....] at the right of the
property field and create a query by adding your OLE table to the form's
table.

Damon

David said:
I'm trying to figure out a way to attach a file to a attachment feild in
Access 2007.

Basically, the file would be located in My Documents and always be called
AccuData.txt

I assume this would require some sort dao commands, which are a little
out
of my league.

Any help would be great

Thank You
 
D

Damon Heron

Well, you could use this for a click event:

Private Sub Command1_Click()
Shell ("C:\<Folder where file is>\notepad.exe AccuData.txt")
End Sub

With the ole routine, the txt file will open on your screen, but this way it
will open minimized on the task bar.

Damon

David said:
Actually, this process would be part of a command button on another part
of
the form. So, it would need to be code since the user would not be
clicking
on the actual attachment field.

Hope this makes sense

Thank you for your previous suggestions.
David


Damon Heron said:
I meant
"No coding required, if all you want is a file that can be displayed by
dbl-clicking on an object on a
form."

Damon Heron said:
No coding required, if all you want is a file that can be displayed on
a
form that you can dbl-click on to open.
Create a table with one field - OLEObject. Save then open the table
and
right click to create from file. Browse to your file and slect.
Save table.
On your form, Put an OLE Object and set the control source to your
table
field. Dbl-click to open the text file.
If the form is bound to another table, then you will need to amend the
Record Source of the table by clicking on the [....] at the right of
the
property field and create a query by adding your OLE table to the
form's
table.

Damon

I'm trying to figure out a way to attach a file to a attachment feild
in
Access 2007.

Basically, the file would be located in My Documents and always be
called
AccuData.txt

I assume this would require some sort dao commands, which are a little
out
of my league.

Any help would be great

Thank You
 
D

Damon Heron

Oops! Replace the code with
Private Sub Command1_Click()
dim x as variant
x = Shell("C:\<your folder>\notepad.exe AccuData.txt", vbNormalFocus)

This will open on screen.

Damon

Damon Heron said:
Well, you could use this for a click event:

Private Sub Command1_Click()
Shell ("C:\<Folder where file is>\notepad.exe AccuData.txt")
End Sub

With the ole routine, the txt file will open on your screen, but this way
it will open minimized on the task bar.

Damon

David said:
Actually, this process would be part of a command button on another part
of
the form. So, it would need to be code since the user would not be
clicking
on the actual attachment field.

Hope this makes sense

Thank you for your previous suggestions.
David


Damon Heron said:
I meant
"No coding required, if all you want is a file that can be displayed by
dbl-clicking on an object on a
form."

No coding required, if all you want is a file that can be displayed on
a
form that you can dbl-click on to open.
Create a table with one field - OLEObject. Save then open the table
and
right click to create from file. Browse to your file and slect.
Save table.
On your form, Put an OLE Object and set the control source to your
table
field. Dbl-click to open the text file.
If the form is bound to another table, then you will need to amend the
Record Source of the table by clicking on the [....] at the right of
the
property field and create a query by adding your OLE table to the
form's
table.

Damon

I'm trying to figure out a way to attach a file to a attachment feild
in
Access 2007.

Basically, the file would be located in My Documents and always be
called
AccuData.txt

I assume this would require some sort dao commands, which are a
little
out
of my league.

Any help would be great

Thank You
 

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