VB Code Access 2002 Form

J

John

I copied some code from the northwind database to my new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i copied
is all the code in the employees form for all the events
needed. well i go to run my form and push the add/change
button and the compile error comes up with the (variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John
 
C

Cheryl Fischer

If I remember correctly, you will need to set a reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt-F11. Then, from the
Visual Basic menu, select Tools|References. Scroll through the list of
available references until you find the correct one and click the checkbox
to the left of the Reference name.



hth,
 
G

Guest

Thank you very much Ms.Fischer that worked but know i get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt- F11. Then, from the
Visual Basic menu, select Tools|References. Scroll through the list of
available references until you find the correct one and click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


I copied some code from the northwind database to my new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i copied
is all the code in the employees form for all the events
needed. well i go to run my form and push the add/change
button and the compile error comes up with the (variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog (msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John


.
 
C

Cheryl Fischer

Me![ImagePath] refers to a control on the Employees form. It is a textbox
(located within/under the ImageFrame control) and is bound to the field
Photo. In the design view of your form, make sure that you do have this
control and that the spelling of the control name is exactly the same as in
the code, as that is typically the reason for this error.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Thank you very much Ms.Fischer that worked but know i get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt- F11. Then, from the
Visual Basic menu, select Tools|References. Scroll through the list of
available references until you find the correct one and click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


I copied some code from the northwind database to my new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i copied
is all the code in the employees form for all the events
needed. well i go to run my form and push the add/change
button and the compile error comes up with the (variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog (msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John


.
 
J

John

Thank you very much Ms.Fischer that worked but know i get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt- F11. Then, from the
Visual Basic menu, select Tools|References. Scroll through the list of
available references until you find the correct one and click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


I copied some code from the northwind database to my new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i copied
is all the code in the employees form for all the events
needed. well i go to run my form and push the add/change
button and the compile error comes up with the (variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog (msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John


.
 
J

John

Okay once again your the expert..and it worked Yes!!!..I
changed the textbox in my form to that name. Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus.... I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem?? What do i do
know....Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path....THANKS AGAIN FOR
YOUR TIME AND Help would you belive i have been
researching this for the last 8 hrs before i posted
this...man you are great....

John
-----Original Message-----
Me![ImagePath] refers to a control on the Employees form. It is a textbox
(located within/under the ImageFrame control) and is bound to the field
Photo. In the design view of your form, make sure that you do have this
control and that the spelling of the control name is exactly the same as in
the code, as that is typically the reason for this error.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Thank you very much Ms.Fischer that worked but know i get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing
Alt-
F11. Then, from the
Visual Basic menu, select Tools|References. Scroll through the list of
available references until you find the correct one
and
click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


I copied some code from the northwind database to my new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i copied
is all the code in the employees form for all the events
needed. well i go to run my form and push the add/change
button and the compile error comes up with the (variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog (msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John



.


.
 
C

Cheryl Fischer

Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus

Make sure that you have a control on your form named FirstName and that its
Visible property is set to True
I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem??

That field is supposed to contain the file name of the photo.
Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path

In the code, change the .InitialFileName property from CurrentProject.Path
to "C:\picture"


--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


John said:
Okay once again your the expert..and it worked Yes!!!..I
changed the textbox in my form to that name. Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus.... I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem?? What do i do
know....Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path....THANKS AGAIN FOR
YOUR TIME AND Help would you belive i have been
researching this for the last 8 hrs before i posted
this...man you are great....

John
-----Original Message-----
Me![ImagePath] refers to a control on the Employees form. It is a textbox
(located within/under the ImageFrame control) and is bound to the field
Photo. In the design view of your form, make sure that you do have this
control and that the spelling of the control name is exactly the same as in
the code, as that is typically the reason for this error.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Thank you very much Ms.Fischer that worked but know i get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a
reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt-
F11. Then, from the
Visual Basic menu, select Tools|References. Scroll
through the list of
available references until you find the correct one and
click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


message
I copied some code from the northwind database to my
new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i
copied
is all the code in the employees form for all the
events
needed. well i go to run my form and push the
add/change
button and the compile error comes up with the
(variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here is the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog
(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John



.


.
 
J

John

Thanks again i must close down for the day but will be at
it more tommorrow will you be around ....I will have some
more questions i am sure thank you again Ms. Fischer....

John
-----Original Message-----
Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus

Make sure that you have a control on your form named FirstName and that its
Visible property is set to True
I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem??

That field is supposed to contain the file name of the photo.
Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path

In the code, change the .InitialFileName property from CurrentProject.Path
to "C:\picture"


--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Okay once again your the expert..and it worked Yes!!!..I
changed the textbox in my form to that name. Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus.... I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem?? What do i do
know....Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path....THANKS AGAIN FOR
YOUR TIME AND Help would you belive i have been
researching this for the last 8 hrs before i posted
this...man you are great....

John
-----Original Message-----
Me![ImagePath] refers to a control on the Employees form. It is a textbox
(located within/under the ImageFrame control) and is bound to the field
Photo. In the design view of your form, make sure
that
you do have this
control and that the spelling of the control name is exactly the same as in
the code, as that is typically the reason for this error.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Thank you very much Ms.Fischer that worked but know
i
get
another error runtime error 2465 Microsoft cant find the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a
reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing Alt-
F11. Then, from the
Visual Basic menu, select Tools|References. Scroll
through the list of
available references until you find the correct one and
click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


message
I copied some code from the northwind database to my
new
database. I developed a form like the employees form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in my db
on my form I started fresh...well the code that i
copied
is all the code in the employees form for all the
events
needed. well i go to run my form and push the
add/change
button and the compile error comes up with the
(variable
not defined error) Here is the variable it talks about
not being defined(msoFileDialogFilePicker) here
is
the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog
(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item (1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John



.



.


.
 
C

Cheryl Fischer

You're welcome, John. Post back anytime - that is what we are here for.

By the way, we are all on a first-name basis here, so call me Cheryl!

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


John said:
Thanks again i must close down for the day but will be at
it more tommorrow will you be around ....I will have some
more questions i am sure thank you again Ms. Fischer....

John
-----Original Message-----
Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus

Make sure that you have a control on your form named FirstName and that its
Visible property is set to True
I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem??

That field is supposed to contain the file name of the photo.
Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path

In the code, change the .InitialFileName property from CurrentProject.Path
to "C:\picture"


--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Okay once again your the expert..and it worked Yes!!!..I
changed the textbox in my form to that name. Only know i
am getting the same error message but its referring to
this line of code Me![FirstName].SetFocus.... I have a
field in my table that is called photo and in that field
i have the name of my pictures( example
picture1.jpg)...is this causing my problem?? What do i do
know....Also when the FileDialogFilePicker comes of to
pic the file it goes to my document folder ....I have a
folder on the C:/ root called picture how do I get the
box to come up and go to that path....THANKS AGAIN FOR
YOUR TIME AND Help would you belive i have been
researching this for the last 8 hrs before i posted
this...man you are great....

John
-----Original Message-----
Me![ImagePath] refers to a control on the Employees
form. It is a textbox
(located within/under the ImageFrame control) and is
bound to the field
Photo. In the design view of your form, make sure that
you do have this
control and that the spelling of the control name is
exactly the same as in
the code, as that is typically the reason for this error.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Thank you very much Ms.Fischer that worked but know i
get
another error runtime error 2465 Microsoft cant find
the
field "ImagePath"in my expression... In the code it is
this line Me![ImagePath].Visible = True that i am
getting this ....thanks again i am new to this...

John
-----Original Message-----
If I remember correctly, you will need to set a
reference to the Microsoft
Office 10.0 Object Library.

To set references, open any code module by pressing
Alt-
F11. Then, from the
Visual Basic menu, select Tools|References. Scroll
through the list of
available references until you find the correct one
and
click the checkbox
to the left of the Reference name.



hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


message
I copied some code from the northwind database to my
new
database. I developed a form like the employees
form in
northwind db the code for the add/change and remove
buttons is what i copied ....no other code was in
my db
on my form I started fresh...well the code that i
copied
is all the code in the employees form for all the
events
needed. well i go to run my form and push the
add/change
button and the compile error comes up with the
(variable
not defined error) Here is the variable it talks
about
not being defined(msoFileDialogFilePicker) here is
the
code.How do I define the variable

Sub getFileName()
' Displays the Office File Open dialog to
choose a
file name
' for the current employee record. If the user
selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog
(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item (1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

thanks in advance

John



.



.


.
 

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