By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Browse for Folder, I am still missing something

P: n/a
DD
Hi
Ok, i have loaded the appropriate code to call the Browse Save As
dialog box

I click a Btn from my Access form then the Dialog box appears i can
choose any file However i want to pass the file i choose to a text box
on the form
I know have included this code behind the Btn on the Form Private Sub cmdOpen_Click()

Dim strFile As String
strFile = TestIt
If Len(strFile) > 0 Then
Me!txtFile = strFile
Me![Text4] = (TestIt)

End If
End Sub

Still no show!
What am i missing???
Any assistance would be great

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
What is TestIt? Is this code that is returning the selected file? If so,
make sure that the TestIt code is actually returning a file name, or post
the code beind Testit.

--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

"DD" <da**********@bigpond.com.au> wrote in message
news:14**************************@posting.google.c om...
Hi
Ok, i have loaded the appropriate code to call the Browse Save As
dialog box

I click a Btn from my Access form then the Dialog box appears i can
choose any file However i want to pass the file i choose to a text box
on the form
I know have included this code behind the Btn on the Form

Private Sub cmdOpen_Click()

Dim strFile As String
strFile = TestIt
If Len(strFile) > 0 Then
Me!txtFile = strFile
Me![Text4] = (TestIt)

End If
End Sub

Still no show!
What am i missing???

Any assistance would be great

Nov 12 '05 #2

P: n/a
On 5 Jan 2004 14:15:45 -0800, da**********@bigpond.com.au (DD) wrote:
Hi
Ok, i have loaded the appropriate code to call the Browse Save As
dialog box

I click a Btn from my Access form then the Dialog box appears i can
choose any file However i want to pass the file i choose to a text box
on the form
I know have included this code behind the Btn on the Form

Private Sub cmdOpen_Click()

Dim strFile As String
strFile = TestIt
If Len(strFile) > 0 Then
Me!txtFile = strFile
Me![Text4] = (TestIt)

End If
End Sub

Still no show!
What am i missing???

Any assistance would be great


The TestIt function doesn't return anything. Try working with the
GetOpenFile() function. There is some in-line annotation that should
help.

- Jim
Nov 12 '05 #3

P: n/a
David,

I managed to make it work... here's the modified code...

Apologies to Ken Getz for messing with his code, but it does what you want...

'---in a separate module....

Function TestIt() As Variant '<---changed the return type to Variant
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
'MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.

'---I bastardized this line...
TestIt = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
Debug.Print Hex(lngFlags)
End Function

button code on a form:
Option Compare Database
Option Explicit

Private Sub cmdTestIt_Click()
Dim varFile As Variant
varFile = TestIt()

If Not IsNull(varFile) Then
Me.txtFileName.SetFocus
Me.txtFileName.Text = varFile
End If

End Sub

Don't know if the function should return a string or not, but it *does* work...

HTH, and apologies for the butcher job...
Pieter
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.