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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move controls based on the size of other controls

Status
Not open for further replies.

ghacig

Technical User
Sep 24, 2004
60
US
Hi All,

I have two controls side by side on a report. There is usually a space between them because the size of the content can vary. I want the one to the right to appear on the report immediately next to the one on the left. I need to move the right field to be next the left, based on the size of the left field?
 
Is there a reason you don't concatenate the fields together in a single text box?
=FirstName & " " & LastName
If this isn't feasible, you could print the field values with code. Would you like a sample coding method? Maybe you could provide a couple field names.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
I assume you're talking about the size of the content rather than of the control--unless you're changing the left control's Width property?

It's very difficult to determine the display width of text. It can be done with API calls, but it takes a lot of VBA code and is all very foreign stuff to VBA programmers.

A simpler solution would be to use a single text box control wide enough for both fields, and use a string concatenation expression as the source for the single text box. For example, if the fields you want to display are FirstName and LastName, you would set the text box's Control Source to [blue]=[FirstName] & " " & [LastName][/blue].

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
To get something like
[tt]
Joe[red]Smith[/Red]
Bartholemule[red]Smith[/Red]
[/tt]
Actually it can be as easy as

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.CurrentX = 2880 '2 inches from left
    Me.CurrentY = 360  '1/4 inch down
    Me.Print Me.txtFirstName
    Me.CurrentY = 360
    Me.FontBold = True
    Me.ForeColor = vbRed
    Me.Print Me.txtLastName
    Me.FontBold = False
    Me.ForeColor = vbBlack
End Sub

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Duane: Are you talking about Access? What version? VB6 forms have these properties and methods, but Access 2000 forms don't.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
This is a question about reports. I don't think forms have similar capabilities unless your name is Stephen Lebans (
Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Oops! I'm switching between threads too quickly and losing track. Thanks. (I didn't know you could do it on reports either, actually.)

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thank you very much guys. Concatenation into a single text box worked well. Sorry for the delay, I was trying to survive Hurricane Jeanne here in Florida.
Appreciate your help.

Georges Ghacibeh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top