Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Public Variable - not defined?

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
..
..
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Public Variable - not defined?

Do you use the stand alone line of code

End

That line of code kills everything including clearing all global variables.
--
HTH...

Jim Thomlinson


"Clayman" wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Public Variable - not defined?

No. But, I do have a few "Exit Sub" in error-handlers. Would these have the
same effect?

I don't know if it matters, and didn't think about mentioning it before. The
code in Module 1 fills a ComboBox on a form (employee numbers). Selecting an
item in the ComboBox executes the next set of code - which is where I'm told
the variable is not defined.

The variable is the path to my database which may differ depending upon the
user.
--
Adios,
Clay Harryman


"Jim Thomlinson" wrote:

Do you use the stand alone line of code

End

That line of code kills everything including clearing all global variables.
--
HTH...

Jim Thomlinson


"Clayman" wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Public Variable - not defined?

Try putting this line in a general module.

Public findvacdb As String

(delete then line within the ThisWorkbook module)

or

refer to that variable by its fully qualified name:
msgbox ThisWorkbook.findvacdb





Clayman wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Public Variable - not defined?

That sounds logical. I'll give it a shot.

I thought "ThisWorkbook" would be a general module. In layman's terms: click
Insert|Module, right? Then, at the top of it put my Public declaration?

Seems the easiest way to go.

Thanks!
--
Adios,
Clay Harryman


"Dave Peterson" wrote:

Try putting this line in a general module.

Public findvacdb As String

(delete then line within the ThisWorkbook module)

or

refer to that variable by its fully qualified name:
msgbox ThisWorkbook.findvacdb





Clayman wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Public Variable - not defined?

A couple of things...
1. When in doubt try being more specific in your referencing
msgbox Module1.findvacdb
2. All users ultimately have the same path to the file. They may have
different drive letters but you can use the full URL. For example your S
drive is mapped something like \\Myserver\Something

In windows explorer you will see the full path besid ethe drive letter or in
Tools - map directory
--
HTH...

Jim Thomlinson


"Clayman" wrote:

No. But, I do have a few "Exit Sub" in error-handlers. Would these have the
same effect?

I don't know if it matters, and didn't think about mentioning it before. The
code in Module 1 fills a ComboBox on a form (employee numbers). Selecting an
item in the ComboBox executes the next set of code - which is where I'm told
the variable is not defined.

The variable is the path to my database which may differ depending upon the
user.
--
Adios,
Clay Harryman


"Jim Thomlinson" wrote:

Do you use the stand alone line of code

End

That line of code kills everything including clearing all global variables.
--
HTH...

Jim Thomlinson


"Clayman" wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Public Variable - not defined?

I thought "ThisWorkbook" would be a general module. In layman's terms:
click
Insert|Module, right? Then, at the top of it put my Public declaration?


Nope, ThisWorkbook is a class module not a regular module. As such, you must
include its name to access any variable declared in the module. E.g.,

ThisWorkbook.SomeVariable = 123

If you omit the "ThisWorkbook", VBA won't find SomeVariable.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Clayman" wrote in message
...
That sounds logical. I'll give it a shot.

I thought "ThisWorkbook" would be a general module. In layman's terms:
click
Insert|Module, right? Then, at the top of it put my Public declaration?

Seems the easiest way to go.

Thanks!
--
Adios,
Clay Harryman


"Dave Peterson" wrote:

Try putting this line in a general module.

Public findvacdb As String

(delete then line within the ThisWorkbook module)

or

refer to that variable by its fully qualified name:
msgbox ThisWorkbook.findvacdb





Clayman wrote:

I apologize if this got double-posted. I think I need to go home and
take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I
defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing
brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman


--

Dave Peterson


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Public Variable - not defined?

I sincerely appreciate the help. I owe y'all a happy hour or something like
that. :)

When I got my degree in CS, only linear programming courses were required.
OOP was an elective, which I skipped thinking I wouldn't really need it. Then
I went into Networking and Support instead of programming.

Well, now that I'm (much) older, and I hate lugging PCs and laser printers,
I wanted to get back into programming. This project is my first foray back
into the field. While much of it is still very intuitive, I've come to the
conclusion that I need to return to school to learn about object-oriented
programming. It's not going to stop me from working in the field. It will
only enhance what I have to offer.

Again, thank you so much for all the help you've provided over the last two
months. I would not have been able to complete this project without you.
--
Adios,
Clay Harryman
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Public Variable - not defined?

That's going to happen once we decide exactly where all this will reside. For
development purposes I'm using the drive letter.

--
Adios,
Clay Harryman


"Jim Thomlinson" wrote:

A couple of things...
1. When in doubt try being more specific in your referencing
msgbox Module1.findvacdb
2. All users ultimately have the same path to the file. They may have
different drive letters but you can use the full URL. For example your S
drive is mapped something like \\Myserver\Something

In windows explorer you will see the full path besid ethe drive letter or in
Tools - map directory
--
HTH...

Jim Thomlinson


"Clayman" wrote:

No. But, I do have a few "Exit Sub" in error-handlers. Would these have the
same effect?

I don't know if it matters, and didn't think about mentioning it before. The
code in Module 1 fills a ComboBox on a form (employee numbers). Selecting an
item in the ComboBox executes the next set of code - which is where I'm told
the variable is not defined.

The variable is the path to my database which may differ depending upon the
user.
--
Adios,
Clay Harryman


"Jim Thomlinson" wrote:

Do you use the stand alone line of code

End

That line of code kills everything including clearing all global variables.
--
HTH...

Jim Thomlinson


"Clayman" wrote:

I apologize if this got double-posted. I think I need to go home and take a
nap rather than continue to foul this computer up anymore today with my
presence. :P

--

I need "findvacdb" to be the same across my entire project so I defined it
in "This Workbook" as Public:

Option Explicit
Public findvacdb As String

Private Sub Workbook_Open()
.
.
findvacdb=S:\Path\to\mdb

When I try to use it in a form, I get the error "Variable not defined".

I'm tired and I just had a big lunch. Maybe it's the hamburger killing brain
cells. But I can't figure this out.

If you need more code, let me know.

Thanks!
--
Adios,
Clay Harryman

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Public Variable Marvin Excel Programming 1 March 29th 07 09:50 PM
Public variable Eric[_35_] Excel Programming 7 March 18th 07 06:54 AM
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"