Put string into Form field

treva26

Registered User.
Local time
Today, 03:42
Joined
Sep 19, 2007
Messages
113
A very basic question, but I am new to this...

I have the following code to get the path of an image from my form, and it works fine.
I just need to get the resulting string into the correct field on my form.
The field I want to put it in is [Photo].

Code:
Sub openfile2()

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Image Files (*.BMP)", "*.BMP")

strInputFileName = ahtCommonFileOpenSave( _
                Filter:=strFilter, OpenFile:=True, _
                DialogTitle:="Please select an image file...", _
                Flags:=ahtOFN_HIDEREADONLY)

' [Photo] = strInputFileName ???
                
End Sub

The code is called from a button on my form.
 
well off the top of my head it looks like what you've already got should work, So I am a bit puzzles as to your question?

I believe this should work, as long as "Photo" is a text field on your form and can handle the number of characters returned by "strInputFileName"
Me.Photo = strInputFileName

is the field "photo" bound to a table? If it is what is the field size in the table?

A simple check you can do would be to include a message box like this:

MsgBox " >>> " & strInputFileName ' To examine the string returned
Me.Photo = strInputFileName
 
Hi,

Where is this code located, Form's module or a Standard module?

A very basic question, but I am new to this...
I have the following code to get the path of an image from my form, and it works fine.
I just need to get the resulting string into the correct field on my form.
The field I want to put it in is [Photo].
snip.. reduce space
The code is called from a button on my form.
 
Last edited:
Ok well I think it may be that my button is unrelated to the photo text field?
Its just a button I made and told it to call the Sub.

The MsgBox does work, it tells me the correct path.

But when I try:

Code:
[Photo] = strInputFileName

it says "External name not defined"

and when I try:

Code:
Me.Photo = strInputFileName

it says "Invalid use of Me keyword"

does that shed any light?
 
As Uncle Joe says: Where is this code?

If it's not in the form where the "photo" text box is then it won't work.
 

Users who are viewing this thread

Back
Top Bottom