Global variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tigger
    New Member
    • May 2007
    • 37

    Global variable

    Hi,
    I'm having problems with variables. I have this variable 'count' in my vb program. And i need to use this variable in my Access database to create a SELECT statement. I think i need to make it as a global variable. How do i go about doing that?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by tigger
    I'm having problems with variables. I have this variable 'count' in my vb program. And i need to use this variable in my Access database to create a SELECT statement. I think i need to make it as a global variable. How do i go about doing that?
    This is rather a confusing question, in some ways.

    Is this "VB program" actually a VBA module within Access? When you say you need to "use this variable in my Access database" what do you mean, exactly? I don't think there's any way MS Access can see a variable in another application. Do you just mean that your VB program needs to use it in building a query to run against an Access database, or what?

    If this is VBA, presumably it's built into Access. If so, what version of Access? If not, what version of VB are you using?

    Comment

    • tigger
      New Member
      • May 2007
      • 37

      #3
      Originally posted by Killer42
      This is rather a confusing question, in some ways.

      Is this "VB program" actually a VBA module within Access? When you say you need to "use this variable in my Access database" what do you mean, exactly? I don't think there's any way MS Access can see a variable in another application. Do you just mean that your VB program needs to use it in building a query to run against an Access database, or what?

      If this is VBA, presumably it's built into Access. If so, what version of Access? If not, what version of VB are you using?

      Sorry i didnt make things clear. I'm using Visual Basic 2005. And i'm using Microsoft Access 2003. Yes, my VB program needs to use the variable "count" in building a query to run against an Access database.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I work with VB6, and don't know the details of how you create global variables in VB2005. But once you have it, just concatenate it into your SQL string. For example, say you're creating a simple query to find all records in a table with a field greater than the value in your Count variable. You would probably do something like...

        [CODE=vb]strSQL = "SELECT * FROM TableName WHERE FieldName > " & Format$(Count) & ";"[/CODE]Then use strSQL as the source of your database query.

        Comment

        • hariharanmca
          Top Contributor
          • Dec 2006
          • 1977

          #5
          Originally posted by tigger
          Sorry i didnt make things clear. I'm using Visual Basic 2005. And i'm using Microsoft Access 2003. Yes, my VB program needs to use the variable "count" in building a query to run against an Access database.

          Whatever variable you’ll use, it accept only by VBA.

          Solution:
          Code:
          Declare variable as it is.
          Use one more field in Database for Count.
          Append or update that variable value to that field.
          I don’t prefer for such combination like VB 2005 and backend MS Access 2003.
          Think which technology is better to our project.
          For simple project you are forcing your user to install latest framework.
          Good luck.

          Comment

          Working...