Results 1 to 4 of 4
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Why does the compiler say this variable is undefined

    In the attached file which is my current db why does it say on compile that variable

    ysnMeetingID

    is not defined in the VBA code.

    It certainly is as anyone can see when they open form frmEnail.

    This just does not make any sense. I have also attached a screenshot of the affected code.

    Any help appreciated. Thanks in advance.



    Respectfully,

    Lou Reed
    Attached Files Attached Files
    Last edited by Lou_Reed; 04-18-2017 at 01:38 PM. Reason: correction

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    I don't see any declaration at top of that code in PDF

    Dim ysnMeetingID as Integer

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Does ysnMeetingID need to declared? It is used at least once when the form opens up. At that point
    ysnMeetingID has a value of 1. It is used as a control source for one of the text boxes.

    I understand that variables must be defined before they are used, but it seems that control source should do the trick instead of explicit variable definition. I guess that I am wrong. Of course I am wrong, but it seems that others get away with it.

    Look at the attached db file that I know runs. Look at the txtTicketID variable. I do not see anywhere where it is defined. Yet it is used.

    Please explain.

    Respectfully,

    Lou Reed
    Attached Files Attached Files
    Last edited by Lou_Reed; 04-19-2017 at 06:39 AM. Reason: correction

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    in the case of txtTicketID, this is not a variable in VBA.

    me.txtticketID is a textbox on the form and so does not need to be defined


    stTicketID is being used as a storage area for the value of that textbox and that space needs to be declared using a dim statement.

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

Similar Threads

  1. Compiler ignoring the with/Do in a loop?
    By tonygg in forum Programming
    Replies: 1
    Last Post: 10-13-2015, 05:26 AM
  2. compiler error
    By Sheba in forum Forms
    Replies: 20
    Last Post: 10-03-2014, 12:41 PM
  3. Access 2007 Runtime Compiler
    By burrina in forum Security
    Replies: 9
    Last Post: 01-23-2013, 06:20 PM
  4. Compiler error: Method or member not found
    By JosmithTwo in forum Programming
    Replies: 3
    Last Post: 11-26-2012, 07:10 AM
  5. Compiler WRONG example-DB
    By pacala_ba in forum Access
    Replies: 12
    Last Post: 04-18-2009, 01:00 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