CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Text-Manipul. in Access

    My problem is cutting off two characters from the left side in a MS Access-Query. I know that there are bulid-in functions in the expression builder, but I don't know which fits and how I can get my column data in there.
    Thanks for helping.


  2. #2
    Join Date
    Jul 1999
    Posts
    2

    Re: Text-Manipul. in Access

    Here is the code you could insert in your query, assuming that a two (or less) characters long string
    would be completely cut off. Maybe there's a more simple way to do it, but this example should work.

    croppedstr: Iif(Len(str) < 2, Null, Right(str, Len(str) - 2))


  3. #3
    Join Date
    Jul 1999
    Posts
    1

    Re: Text-Manipul. in Access

    Thank you very much! I have further problems implementing this, because
    I'am real beginner in VB. Could you help me again declaring the variables in access so that I can use it in a query or should I write a module?
    I assume your formula cuts-off the two last characters, is this right? If I want
    the first two I have to use left() I suppose.
    Thanks in advance.



  4. #4
    Join Date
    Jul 1999
    Posts
    2

    Re: Text-Manipul. in Access

    Well, this function should cut off the first two characters, did you try it?

    You can use a VB variable in a query, for that purpose you should create a function that returns this
    variable everytime it's called, i.e. :


    '--------------------------------------
    ' module1
    Global Variable as <type>
    '
    ' module2
    ' [...]
    Variable = <value>
    ' [...]
    '
    ' module3
    Function GetVariable() as <type>

    GetVariable = Variable
    End Function
    '---------------------------------------




    You can use this GetVariable() function in all your queries (don't forget the parenthesis) just like a built-in
    Access function. Note that the VB declarations could be part of the same module.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured