?
Solved

like values

Posted on 2007-11-23
11
Medium Priority
?
135 Views
Last Modified: 2010-04-30
I have a table that stores data of things to do at various locations it can store up to six locations(location0 to location7) now at each location there can be 3 different thing to be done.what i would like to do is this have 4 text boxes
location     item              item1       item2     now if the items are at the same location then display then on the same line in each textbox else for every different location we would start a new line. eg

location        item     item1      item2
location0        1            2           3
location1                       4         5
location2       6                         7
so at location0 we are going to do all 3 items,at location1 we are only going to do item1and item2 and at location2 item and item3.etc.etc.
thanks
0
Comment
Question by:wwstudioinc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20338777
It is difficult (but not impossible) to space out text accurately inside text boxes.

I think that you would be better off using, either a grid, or a textbox for each item/location combination.

With text boxes, you could use a control array of 30 text boxes. Simple algorithms could translate the box's index to location and item or vice versa.

Or you could have 3 control arrays (one per item) txtItem0(0), txtItem0(1),txtItem0(2) then txtItem1(0), txtItem1(1),txtItem1(2).

In the same vein, there could be one array per location - txtLocation0(0), txtLocation0(1), txtLocation0(2), txtLocation0(3), txtLocation0(4), txtLocation0(5), txtLocation0(6), txtLocation0(7),txtLocation0(8), txtLocation0(9).
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 20338827
This is how to align the text so that each item's text displays at a particular offset.
Private Sub Command1_Click()
     Dim strText As String
    Const strItem1 = "abc"
    Const strItem2 = "def"
    Const strItem3 = "ghi"
    
    Set Me.Font = Text1.Font 'match form's font to text box's font
    
    strText = strItem1 ' first item in string
    Do Until Me.TextWidth(strText) >= 500
        strText = strText & " " 'space out to 500
    Loop
    strText = strText & strItem2 'append second item after spacing out
    Do Until Me.TextWidth(strText) >= 1000
        strText = strText & " " 'space out to 1000
    Loop
    strText = strText & strItem3
    Text1.Text = strText
End Sub

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 20338982
>> I think that you would be better off using, either a grid, or a textbox for each item/location combination.

Maybe because I use it allot, why don't you use a listview for that (like GrahamSkan suggest it) ?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:wwstudioinc
ID: 20339498
guys that for the response but does anyone has an example.i have no clue.I am trying to avoid having to use too many text boxes
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20339535
Which option do you want code for? The code that I have provided is intended to illustrate how to do what you ask for, that is to space out the text inside a text box so that it resembles columns.
Does that help?
0
 

Author Comment

by:wwstudioinc
ID: 20339559
how would you go about using an array for each location
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 20339748
Is the listview with multiple columns a soluction for your ? Do you like an example ?
0
 

Author Comment

by:wwstudioinc
ID: 20339750
i have been playing around with something like this but the only problem i would have is to ensure then the vbcrlf falls in the same place.let's say the first line goes pass the width of the text box that a new line would start for that text box which would fall into the same position the other vbcrllf in the same position.

For i = 0 To 7
 
  Me.location  = Me.location  & rs.Fields("location" & i) & vbCrLf & vbCrLf
 Me.txtl = Me.txtl & rs.Fields(" item" ) & vbCrLf & vbCrLf
Me.txts= Me.txts & rs.Fields(" item1) & vbCrLf & vbCrLf
 Me.txth = Me.txth & rs.Fields(" item2i) & vbCrLf & vbCrLf

Next
this is pretty close to what i am looking for
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 2000 total points
ID: 20339825
Set up a column of text boxes called Location0, Location1, Location2, etc. Set the Index property to each one to 0, thus creating 10 control arrays, each array containing a single control.

You can place the other text boxes on the form in the usual way in design mode,, or you can have this code to automate it for you.




Private Sub Form_Load()
Dim i As Integer
For i = 1 To 2
    Load Me.Location0(i)
    Location0(i).Visible = True
    Location0(i).Top = Location0(i - 1).Top
    Location0(i).Left = Location0(i - 1).Left + Location0(i - 1).Width + 50
    
    Load Location1(i)
    Location1(i).Visible = True
    Location1(i).Top = Location1(i - 1).Top
    Location1(i).Left = Location1(i - 1).Left + Location1(i - 1).Width + 50
    
    Load Location2(i)
    Location2(i).Visible = True
    Location2(i).Top = Location2(i - 1).Top
    Location2(i).Left = Location2(i - 1).Left + Location2(i - 1).Width + 50
 
    Load Location3(i)
    '...
 Next i
End Sub

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20339840
My last comment does not address your last comment, which I hadn't seen.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20340068
I think you are tryoing to do it the hard way. Text boxes are not designed to display text at given particular XY positions.

The easiest and most obvious way to display a database table is to have a data control and a grid.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question