Calling Function

S

Sash

I have the following that I want call from a form. How do I pass the
filename back to the form?



Public Function Frame50_File()
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Import File"
.Filters.Clear
.Filters.Add "Text", "*.txt"
.Filters.Add "All Files", "*.*"
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = "\u:interfaces/import/"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Else
MsgBox "No file selected"
fileName = ""
Forms!MainForm.[Frame50] = Null
End If
If fileName = "" Then Exit Function
End With
End Function
 
S

strive4peace

Hi Sash,

declare the function to return a string

Public Function Frame50_File() as string

to assign fileName to the return value of the function:

If fileName = "" Then
Exit Function
else
Frame50_File = fileName
end if

~~~~~~~~

then, in your code to call the function:

ReturnFilename = Frame50_File()

~~~~~~~

or, if you are just wanting to write the filename to a form control:

Forms!formname!controlname = fileName
DoEvents

DoEvents makes sure the form is updated right away



Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 

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