Sending mouse clicks in code

branston

Registered User.
Local time
Today, 18:24
Joined
Apr 29, 2009
Messages
372
Hi,

Im not really sure how to phrase this, so bear with me!

I have a form. I want the user to be able to add atatchments to one of the fields (stored as OLE object).
Currently it works if you right click and then select "Insert Object" from the list. I was wondering if it was possible to get VBA to do this, so if I just clicked a button it focused on the OLE object field, right clicked and selected insert object for me.

Any ideas?

Thank you
 
No need to code it like that you can use a "file picker" to do it...
Regardsless Storing the attachement as an OLE Object will increase your database size dramaticaly!
 
I think that was what was suggested in one of my previous posts. They sent me to this website: http://www.access-programmers.co.uk/...d.php?t=157460
It looks like it could work, but im finding it very hard to change it to do exactly what i want becasue i have no idea what the code is doing!!
Do you know of a simpler way? Or some coding with a bit more explaination?
I know the OLE objects will make my database huge, im storing them in a seperate one and having links to the 'front end' database, but it has to be done unfortunatley!
 
Yep that will do it... or I assume it will if it is what I presume it is...

The code in there should be pretty much copy paste... thats why it is in the Sample forum. Whats your problem with it?
 
It seemed to be coming up with an error on one of the variables - ill give it another go though. Is there a way to change the code so in the browse file you can go right down to document level? At the moment it only goes to Folders.
 
Just copied it all in again, and it still comes up with an error. It says:

"Compile Error: User-defined type not defined" and highlights the line that says

Public Function SearchFiles(strFolder As String, strSearchPhrase As String)
Dim objFSO As FileSystemObject

Im self taught so might be missing something vital that has to be done.
Thanks
 
OK, things are getting weirder. I was using a similar piece of code to what this FileSystemObject was doing, but there i just defined the variable as 'Object'. When i change this one to 'Object' the error comes up in the
"Dim objFolder As Folder" line instead. Im thinking maybe a different version of access was being used or something? (Although it does seem odd that the sample data worked fine on my machine)
Any idea of an alternative to "Folder"? Would it work if i put them all as "object"??
 
Yep, just as i thought. There were variables defined as:
Dim objFSO As FileSystemObject '*
Dim objFolder As Folder '*
Dim objFiles As Files '*
Dim strFileNames As String
Dim strSubFolder As Folder '*

but if I changed all those with a * to object it works. Im hoping this hasnt ruined the code somewhere else, but it comes up with the right result, so im happy with that!

Thanks namliam, if you hadnt had replied i probably wouldnt have given that code another go!
 
FileSystemObject, Folder etc...
are defined in the Microsoft Scripting Runtime - therefore if you add a reference to this your code will compile without the need to change these types to Object...
 
"Compile Error: User-defined type not defined" and highlights the line that says

Public Function SearchFiles(strFolder As String, strSearchPhrase As String)
Dim objFSO As FileSystemObject
Search the forum, this is a missing reference like Blue already said...
Add the reference and you should be good.

If the sample works and copying the code doesnt, it is usually some setting/reference that you are missing.
 

Users who are viewing this thread

Back
Top Bottom