Link to home
Get AccessLog in
Avatar of drtopserv
drtopservFlag for Israel

asked on

SET default for opening location to choise an attachment

Hi,
How can i set a default location for where to choise a file when i click to choise afile for an attachment field.
also can i limit adding only one file to an attachment of a field.
i need to do it through vba code if possible.
i have access 2010
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

- this need a changes to the registry in the following HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders under Personal key
- read further here:
http://support.microsoft.com/kb/252732
ASKER CERTIFIED SOLUTION
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
SOLUTION
Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
- you need to have References sets on Microsoft Access xx Object Library (from menu > Tools > References)
Avatar of drtopserv

ASKER

does this works in a field type attachment?
how can i do it through a form when the field is an attachment field, may an sample?
also how can i set it to valid only for 1 file to upload .
"does this works in a field type attachment? how can i do it through a form when the field is an attachment field, may an sample"

- i've never use fileDialog or attachment before. i hope you can further work based on the sample and documentation:
http://office.microsoft.com/en-us/access-help/HV080757678.aspx


' get selected filename
 If .Show = True Then
         returnValue = .SelectedItems
         'OR 
         returnValue = .SelectedItems.Item(1)
Else
         MsgBox "You clicked Cancel"
End If

"also how can i set it to valid only for 1 file to upload "
' only 1 file to select. put this within the With fDialog before the filters

.AllowMultiSelect = False
bro, this not working !!
When i click on the pin apear when i hover the mouse on the field typed attachment and got a dialog window for which i have to choose a file, i`m not getting the defualt folder location by attaching ur code to control(field) in the form

- add the following code to the attachment control's "On Enter" event:

Dim strDefaultFolder As String
strDefaultFolder = [The folder you want]
Application.SetOption "Default Database Directory", strDefaultFolder

- this is a solution on default folder for attachment on EE:
https://www.experts-exchange.com/questions/26688072/VBA-event-procedures-to-improve-ATTACHMENTS-control-on-MS-Access-2007-form.html
Wow,this Works!! , but how can i limit only 1 file to upload in there?
- i can't find any arguments related to limit number of file in argument list as per the following link. maybe you can use Validation Rule but i've never done such rule so i could not help further on this:

http://support.microsoft.com/kb/216888 
I`ll check it now.
can i edit the path of the files attached through vba code?
- sorry for the late reply. i miss-look the EE alert on this question.
- i am not sure about this as i can't test this now. but since you bound it to the attachment control, i can't be sure if you can changed it via vba. Other experts might have opinion on this.
thnx anyway.