Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left position text box property

Status
Not open for further replies.

DogLover2006

Technical User
May 12, 2006
64
US
I am looking for code that will find the last textbox on the form and get the left position property number then it is going to add a number to that for a new position of a new textbox. I hope I am explaining this right. Here is example of I mean

Say the textbox left proper is 1000 twips

newLeft = 1000 + 1000
forms!Temp!Var.left = newLeft

I hope this example help you understand what I want the code to do.

Thanks
 
DogLover2006,
Something like this?
Code:
[navy]Function[/navy] MaxLeft([navy]Optional[/navy] ControlType [navy]As[/navy] AcControlType) [navy]As Long[/navy]
[navy]Dim[/navy] ctlCurrent [navy]As[/navy] Access.Control
[navy]For Each[/navy] ctlCurrent [navy]In[/navy] Me.Controls
  [navy]If[/navy] ControlType = 0 Or ctlCurrent.ControlType = ControlType [navy]Then[/navy]
    [navy]If[/navy] ctlCurrent.Left > MaxLeft [navy]Then[/navy]
      MaxLeft = ctlCurrent.Left
    [navy]End If[/navy]
  [navy]End If[/navy]
[navy]Next[/navy] ctlCurrent
[navy]End Function[/navy]

Usage for a text box would be:
[tab][tt]forms!Temp!Var.left = MaxLeft(acTextBox)[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
How are ya DogLover2006 . . .

. . . and in your mind . . . what are the charateristics of the last textbox?

[blue]How would you know the last?[/blue]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1,

The last textbox is left = 8760 and top = 1140
 
What I want it to do is look for the last textbox that was added each time the form is opened and use the left position of that textbox and add this 1680 to it to creat the new position.

I hope I am explaing this right. Here is what I am trying to do.

I have a button that has code that creates a textbox on a form and now I want it to add a textbox in a new position each time the button is clicked on.

 
Roger That DogLover2006 . . .
DogLover2006 said:
[blue]What I want it to do is look for the last textbox that was added each time the form is opened and use the left position of that textbox and add this 1680 to it to creat the new position.[/blue]
How about you create two [blue]Custom db properties[/blue] (these properties are nonvolatile!) [purple]oldLeft[/purple] & [purple]oldTop[/purple] to hold the last values! This way you won't have to search, you just read the custom properties.

Each time you add a textbox you just update the properties! You will of course have to seed your latest current control . . .

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1,

That sounds good. What do you mean by seed? Could you give me an example of custom db properties? I think I know what you mean by it but I just want to see my thoughts is the same as what you mean. thanks
 
DogLover2006 said:
[blue]What do you mean by seed?[/blue]
The initial values to store in the custom properties which could be:
[ol][li]The values of the current last textbox added ([purple]you want to pickup from where you leftoff[/purple]).[/li]
[li]Values that signify [blue]a fresh start[/blue] ([purple]no textboxes placed as yet[/purple]) . . . ie . . . lets say [blue]-1[/blue]. You would detect [blue]-1[/blue] in code and know where to position the first textbox![/li]
[li]OverAll . . . [purple]whatever position values you desire! . . . as old![/purple][/li][/ol]
DogLover2006 said:
[blue]Could you give me an example of custom db properties?[/blue]
Just as controls, objects, forms & reports & tables have properties, so does the DB itself! . . . From the DB window main menu . . . [blue]Tools[/blue] - [blue]StartUp[/blue], shows some of these properties you can set!

[blue]Custom DB properties[/blue] simply means you can add [blue]your own[/blue] to the DB properties collection. Whats great about this collection (as well as table properties) is that [purple]the properties are read/write nonvolatile![/purple] . . . you can close the DB and when you open it again there still there!

Calvin.gif
See Ya! . . . . . .
 
Hit submit too soon . . .

The idea is when you add and position a textbox, you update the [purple]Custom DB Properties[/purple] for the next textbox. AKA . . . you read the DB props and add your constant for the next position of the current!

To continue . . . [blue]your thoughts! . . .[/blue] [thumbsup2]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1,

That is cool I did not nothing about that and I have been using access for six years now. I will try it and let you how thing go. Thanks
 
DogLover2006 . . .

For a [blue]support module[/blue] you can use, have a look here thread702-1236022 . . . about six posts down! [thumbsup2]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top