Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    18

    Unhappy Unanswered: Floating text box

    Howdy,

    does anyone know how to make a text box 'float' on a form. By this, I mean e.g. this text box should keep to the left of the form, even as you use the scroll bar to scroll across the page to the right, you, kinda like how there are floating boxes on webpages that always stay in the top right corner while you scroll all over the webpages.
    "For all have sinned, and fallen short of the glory of God"

    - God speaking through Paul

  2. #2
    Join Date
    Dec 2003
    Posts
    18

    Re: Floating text box

    Hi there,

    Don't know about keeping the text box on the left or right except by coding it's placement to be "on the fly" but, if you put the box in the header, the detail part of the form scrolls up and down, while the header remains visible and static.

    Maybe someone much wiser than I can provide some info on coding for control placements.

    Hope this helps.

    Amadea

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Sure...check out this little one liner

    Code:
    If Me.Txt1.Left <> Abs(Me.CurrentSectionLeft) Then Me.Txt1.Left = Abs(Me.CurrentSectionLeft)
    To try it out, just set your forms' TimerInterval to 1 and place the code into the 'OnTimer' event...like this:

    Code:
    Private Sub Form_Timer()
        If Me.Txt1.Left <> Abs(Me.CurrentSectionLeft) Then Me.Txt1.Left = Abs(Me.CurrentSectionLeft)
    End Sub
    Kind of neat huh. Play with it a bit. Try this one:

    Code:
    If Me.Txt1.Left <> Abs(Me.CurrentSectionLeft) Then Me.Txt1.Left = Me.Txt1.Left + Abs(Me.CurrentSectionLeft)
    The text box whips across the form. You'll get a error once it reaches its' limit but you can work with it to prevent the error. Play with both the CurrentSectionLeft and CurrentSectionTop statements to make whatever control you want float around all over the form. What the heck, play ping pong...heh....make all the controls float around.

    Once you've got the idea, fire up a API timer instead of the form's timer. It'll be cleaner and faster.

    Hope this helps.

  4. #4
    Join Date
    Aug 2003
    Posts
    18
    That was awesome Cyberlynx, now I just need to put the text box in the right place (e.g. not right against the left but rather 1-2cm from the left of the form). If you could help my out with that Cyberlynx, that would be great. Also, forgive my ignorance - what's an API timer?
    "For all have sinned, and fallen short of the glory of God"

    - God speaking through Paul

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    Well...you could do it a couple of different ways (and I'm sure with more time there are many other ways as well). But...to get you going you could try to simply add the distance (in twips) to the end of the statement like so. We're going to add 200:

    Code:
    If Me.Txt1.Left <> Abs(Me.CurrentSectionLeft) Then Me.Txt1.Left = Abs(Me.CurrentSectionLeft) + 200
    Orrrrr....You can dimension a public variable under Option Explicit in the declarations section of your form and then set the variable within your form's 'OnOpen' event to the text boxes Left count. Should look something like this:

    Code:
    Option Compare Database
    Option Explicit
    Dim BoxLeftIs As Long
    ---------------------------------------------------------
    
    Private Sub Form_Open(Cancel As Integer)
        BoxLeftIs = Me.Txt1.Left
    End Sub
    Then change the code located within your form's 'OnTimer' event to this:

    Code:
    Private Sub Form_Timer()
        If Me.Txt1.Left <> Abs(Me.CurrentSectionLeft) + BoxLeftIs Then Me.Txt1.Left = Abs(Me.CurrentSectionLeft) + BoxLeftIs
    End Sub
    The other thingy....
    API is short for (A)pplication (P)rogrammer's (I)nterface (sheesh...must be tired, I had to look it up).
    In any programming language, you can access the functions that are contained withing various system library files otherwise known as DLL's. I'm sure you know what DLL files are. If not...don't worry about it. trust me, you got heap loads of them within your computer system (in particular, the \Window\System and \Windows\System32 folders). The most common are the Windows libraries. Windows itself operates by using the functions contained within these libraries (DLL) files as does MS Access. When we refer to a API call that means we are going to use (call) one of the many functions contained within whichever library we reference within our API call. There simple

    Just kidding....Get a book my freind....there is a LOT to learn and you are well on your way.

  6. #6
    Join Date
    Aug 2003
    Posts
    18
    Thanks heaps for getting me started Cyberlynx. God bless you.
    "For all have sinned, and fallen short of the glory of God"

    - God speaking through Paul

Posting Permissions

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