Results 1 to 11 of 11
  1. #1
    iamraja5 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    16

    variable NOT visible -Please help

    Hi all
    this is driving me nuts, please help. I searched the entire globe for answer.

    I am using access 2007

    Class1 I wrote these codes

    Option Compare Database
    Public status As String
    Option Explicit

    form1 has a button and it has these codes

    Private Sub Command0_Click()
    status = "I am a happy man"


    End Sub

    same form1 has a another button with this code

    Private Sub Command1_Click()
    MsgBox status
    End Sub

    when I click the msgbox is empty??? why this is not msg as "I am a happy man"
    Please make me a happy man.

    Raja

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    try
    Global status as string

  3. #3
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Fisrtly check the names of the 2 buttons.

    Then check that they have an event linked to them i.e. put the form in design view and then right-click on the a button and select properties. Then on the event tab choose [Event Procedure] from the On Click drop-down.

    If they are named correctly and the code is linked to them then make sure you click the buttons in the correct order.

  4. #4
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    try
    Global status as string
    It should work with 'Public status As String' just fine.

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    You did not mention you clicked command0 before you clicked command1. maybe this is the issue?

  6. #6
    iamraja5 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    16
    Hi
    1. Global as string the class did not work, gave me a compile error.
    2. yes, I clicked the comman0 and then command1
    3. Drop down box properties, I am not using a dropdown menu?

    still the msgbox is empty, any other methods or did I miss anything? Please help

  7. #7
    SteveH2508 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    Option Compare Database
    Option Explicit
    Public status As String

    Your option statements should come before your variable declaration - see above

  8. #8
    iamraja5 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    16
    Hi all
    Tried the following
    Class1
    Option Compare Database

    Option Explicit
    Public status As String
    form1 has a button and it has these codes

    Private Sub Command0_Click()
    status = "I am a happy man"
    End Sub

    same form1 has a another button with this code

    Private Sub Command1_Click()
    MsgBox status
    End Sub

    when I click the msgbox is empty??? why this is not msg as "I am a happy man"

    Thanks again all

  9. #9
    SteveH2508 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    What is the Class1 at the top?

    Remove it and it should work providing your Command buttons are called Command0 and Command1

  10. #10
    iamraja5 is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    16
    Thanks All
    This worked, I was placing the codes in Class module, I removed the codes and entered them in the Module it worked. thanks every one for the support.

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Each form has it's own Class Module. It sounds like you were putting your code in a Standard Module rather than the Form's Class Module. Are you ready to follow the link in my sig and mark this thread as Solved?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Invisible/visible box
    By teirrah1995 in forum Forms
    Replies: 4
    Last Post: 10-03-2010, 02:45 AM
  2. Replies: 4
    Last Post: 08-05-2010, 01:26 PM
  3. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  4. On Load, form not visible
    By Bruce in forum Forms
    Replies: 15
    Last Post: 02-24-2010, 04:06 PM
  5. Tab only visible when field = x
    By ecpike in forum Forms
    Replies: 7
    Last Post: 06-08-2009, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums