Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing variables between forms


Hi All,

I have a 2 forms which rely heavily on a variable called -Vendor-. I
have declaired it in the first form as:

-Public Vendor As String-

The only problem is that the second form fails to pick up the data in
this variable.

Can anyone help me please?

Thank you :)


--
Sami82
------------------------------------------------------------------------
Sami82's Profile: http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Passing variables between forms

Hi Sami82,

Try moving

Public Vendor As String


from the userform module to the head of a standard module.

---
Regards,
Norman



"Sami82" wrote in
message ...

Hi All,

I have a 2 forms which rely heavily on a variable called -Vendor-. I
have declaired it in the first form as:

-Public Vendor As String-

The only problem is that the second form fails to pick up the data in
this variable.

Can anyone help me please?

Thank you :)


--
Sami82
------------------------------------------------------------------------
Sami82's Profile:
http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Passing variables between forms


"Sami82" schrieb im
Newsbeitrag ...

Hi All,

I have a 2 forms which rely heavily on a variable called -Vendor-. I
have declaired it in the first form as:

-Public Vendor As String-

The only problem is that the second form fails to pick up the data in
this variable.

Can anyone help me please?

Thank you :)


--
Sami82
------------------------------------------------------------------------
Sami82's Profile:
http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024


Sami82,

declare ist as a public variable in a module, not in a form (which makes it
globally accessible).

cheers,
Stephan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing variables between forms


Thank you for your speedy reply,

Can this be situated in the "ThisWorkbook" section, because the macr
runs automatically on startup

--
Sami8
-----------------------------------------------------------------------
Sami82's Profile: http://www.excelforum.com/member.php...fo&userid=2711
View this thread: http://www.excelforum.com/showthread.php?threadid=47402

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Passing variables between forms

Hi Sam82,

Can this be situated in the "ThisWorkbook" section, because the macro
runs automatically on startup?


No, the global Vendor variable should be declared at the top of a standard
module.

Should you wish to initialise the Vendor variable in the workbook's opening
event, try (in the ThisWorkbook module):

Private Sub Workbook_Open()
Vendor = "Joe Bloggs Inc"
End Sub

---
Regards,
Norman



"Sami82" wrote in
message ...

Thank you for your speedy reply,

Can this be situated in the "ThisWorkbook" section, because the macro
runs automatically on startup?


--
Sami82
------------------------------------------------------------------------
Sami82's Profile:
http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing variables between forms


Hi All,

I have transferred this to a seperate "startup" module which is called
in "ThisWorkbook". Only problem is now I am getting an error when it
gets to my first Public line, the error is:

Compile error:
Invalid attribute in Sub or Function"

How can I fix this but still be able to use my variables across
multiple forms?

Thank you once again


--
Sami82
------------------------------------------------------------------------
Sami82's Profile: http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Passing variables between forms


"Sami82" schrieb im
Newsbeitrag ...

Hi All,

I have transferred this to a seperate "startup" module which is called
in "ThisWorkbook". Only problem is now I am getting an error when it
gets to my first Public line, the error is:

Compile error:
Invalid attribute in Sub or Function"

How can I fix this but still be able to use my variables across
multiple forms?

Thank you once again


--
Sami82


Declare your variable before any sub

Public Vendor As String

Sub xyz
....
end sub

Stephan


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing variables between forms


Worked a treat.

Thank you!


--
Sami82
------------------------------------------------------------------------
Sami82's Profile: http://www.excelforum.com/member.php...o&userid=27111
View this thread: http://www.excelforum.com/showthread...hreadid=474024

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
Passing variables from one sub to another Yasha Avshalumov Excel Programming 4 August 19th 05 04:52 PM
Passing Variables Paula[_3_] Excel Programming 1 August 23rd 04 06:55 PM
passing variables Squid[_2_] Excel Programming 1 July 27th 04 03:47 AM
Passing Variables Tom Ogilvy Excel Programming 0 July 23rd 04 04:19 PM
Passing Variables Royce[_2_] Excel Programming 1 November 20th 03 02:16 PM


All times are GMT +1. The time now is 11:29 AM.

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"