473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

file attachment on MS Access 2007

ddtpmyra
333 100+
Need to know how to do the vba coding on attaching the file

code
Private Sub Command_Click()
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("cmr_filestorage")
rs1.AddNew
Me.author = rs1.Fields("author")
Me.requestor = rs1.Fields("requestor")
Me.deadline = rs1.Fields("deadline")
Me.category = rs1.Fields("category")
Me.descripton = rs1.Fields("description")
Me.file = rs1.Fields("file")

rs1.Update
rs1.Close

MsgBox "New record added"
End Sub

Problem
I can do the file upload to the user interface but when I hit the button to save the new records error message "Object does'nt support this method" and it's pointing to:
Me.file = rs1.Fields("file")

Question
Somebody can show me how to handle this error im kinda new on ms 2007

thanks,
DM
Sep 22 '08 #1
7 5350
DonRayner
489 Expert 256MB
Need to know how to do the vba coding on attaching the file

code
Private Sub Command_Click()
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("cmr_filestorage")
rs1.AddNew
Me.author = rs1.Fields("author")
Me.requestor = rs1.Fields("requestor")
Me.deadline = rs1.Fields("deadline")
Me.category = rs1.Fields("category")
Me.descripton = rs1.Fields("description")
Me.file = rs1.Fields("file")

rs1.Update
rs1.Close

MsgBox "New record added"
End Sub

Problem
I can do the file upload to the user interface but when I hit the button to save the new records error message "Object does'nt support this method" and it's pointing to:
Me.file = rs1.Fields("file")

Question
Somebody can show me how to handle this error im kinda new on ms 2007

thanks,
DM
If you're adding a new record to the table you need to change these lines

Me.author = rs1.Fields("author")....should be rs1.fields("author") = me.author.value
Me.requestor = rs1.Fields("requestor")...... same change as above
Me.deadline = rs1.Fields("deadline")......etc
Me.category = rs1.Fields("category").....etc
Me.descripton = rs1.Fields("description")......etc
Me.file = rs1.Fields("file")....etc
Sep 23 '08 #2
NeoPa
32,556 Expert Mod 16PB
As Don says, you're moving the data the wrong way. You need to move it from the form (Me.) to the record buffer (rs1.).

Having said all that, this is really a quite unnecessarily complicated way to handle something that Access forms do for you anyway, without any work required.

Have a look at some of the wizards.
Sep 23 '08 #3
ddtpmyra
333 100+
Everythings works fine except when I'm saving the file attachment
I tried this but does'nt work

rs.Fields("file") = Me.file.Filename.Value
rs.Fields("file") = Me.file.FileType.Value
rs.Fields("file") = Me.file.FileURL.Value

I need more help on this please.
Sep 23 '08 #4
NeoPa
32,556 Expert Mod 16PB
...
I need more help on this please.
I suggest you pay some more attention to what's already posted then. Simply ignoring responses is not likely to win you too much help.
Sep 23 '08 #5
ddtpmyra
333 100+
NeoPa,

It's the same problem on file attachment if you look on my first post.

I can do the file upload to the user interface but when I hit the button to save the new records error message "Object does'nt support this method" and it's pointing to:
Me.file = rs1.Fields("file")
Sep 23 '08 #6
DonRayner
489 Expert 256MB
Everythings works fine except when I'm saving the file attachment
I tried this but does'nt work

rs.Fields("file") = Me.file.Filename.Value
rs.Fields("file") = Me.file.FileType.Value
rs.Fields("file") = Me.file.FileURL.Value

I need more help on this please.
It needs to be "rs.Fields("file") = me.file.value". Also make sure that you don't have a typo for the field name in your table or in the control name. Add a msgbox "msgbox me.file.value" at the beginning of your sub to see what value you're trying to add.

Try this code and see how it works

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command_Click()
  2. On error goto ErrorPoint
  3.  
  4. Dim db1 as dao.databae, rs1 As dao.Recordset
  5. Set db1 = CurrentDb
  6. set rs1 = db1.OpenRecordset("cmr_filestorage")
  7.  
  8. rs1.AddNew
  9.  
  10. rs1!author = me.author.value
  11. rs1!requestor = me.requestor.value
  12. rs1!deadline = me.deadline.value
  13. rs1!category = me.category.value
  14. rs1!description = me.description.value
  15. rs1!file = me.file.value
  16.  
  17. rs1.Update
  18. rs1.Close
  19.  
  20. set rs1 = nothing
  21. set db1 = nothing
  22.  
  23. MsgBox "New record added"
  24. ExitPoint:
  25. Exit Sub
  26.  
  27. ErrorPoint:
  28. msgbox err.descripton & "  Error# " & err.number
  29. Resume ExitPoint
  30.  
  31. End Sub
  32.  
You will need to make sure that you Microsoft DAO referanced for this code to work.
Sep 23 '08 #7
NeoPa
32,556 Expert Mod 16PB
NeoPa,

It's the same problem on file attachment if you look on my first post.
I wasn't asking for the question to be repeated. I was merely wondering at the fact that you don't seem to have noticed some of the comments already posted.

This whole issue is only a problem because you are trying to bark yourself, when Access makes a perfectly good dog. Check out post #3.

Post #2 answers your problem if you insist on continuing to try to code, what is already built into the functionality of Access forms, yourself.
Sep 23 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
3
by: pd | last post by:
guys, in my web app, i have a simple download button and a href which points to a file on my server, when the user clicks on the button or the link, the file should simply be downloaded to the...
1
by: bloukopkoggelmander | last post by:
Hi all I have a bit of a strange problem where I want to set a table field in Access 2007 to an attachment field, but when I follow the Microsoft workmethod, I get no option in Access for...
9
by: richee | last post by:
Hi all, I am new to Perl but see that it offers some fantastic opportunities and am trying to use it more in problem solving but could do with a little help on a problem thats driving me nuts.......
2
by: Salad | last post by:
In A2003 one can create a linked table using File/GetExternalData/Link/Exchange(). It's a nice feature but by and large fairly useless if I am reading the table structure correctly. The From &...
0
by: ProgrammerChicago | last post by:
Is there any way to upload and download files using the Access 2007 attachment field type in an ASP.NET webpage? I found this article pertaining to SQL Server 2005 (http://aspnet....
0
by: mturner64 | last post by:
I have created a website using VWD 2008. The interface allows a user to enter information such as (first name, last name, donation amount, etc.). I also want to add a feature to upload images and...
5
by: mturner64 | last post by:
I am developing an application using asp.net where a user can enter first name, last name, donation amount, date, et cetera. After the user enters the information and clicks submit, the information...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.