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

MOVING COLUMNS IN REPORT THROUGH CODE

Status
Not open for further replies.

alifyag

MIS
Apr 15, 2002
18
US
hello,
please help. i am in a fix.
i have two columns in a report address and company name.
if the user decides to sort by company name i want company name to be displayed as the first column and address as the second column and vice versa if he selects address.
i wrote the following code in my report open event
If (Forms!frmPublishersSort!cboFields) = "Address" Then
lbl1.Move Left = 1.625 * 1440
txt1.Move Left = 1.625 * 1440
txt2.Move Left = 0.0417 * 1440
lbl2.Move Left = 0.0417 * 1440
etc etc...
lbl1 and txt1 are coompany name headings and data
lbl2 and txt2 are address headings and data
now what happens is address shifts to the 1st column position but company name doesnt shift to second column position as i result the first column is a mishmash of both.
1.625 and 0.0417 represent the inches position of the column and they r multiplied by 1440 to convert to twips..
please help
alifya
 
The way I handle this is to make the labels unbound text boxes and dynamically create the label depending on the name of the first field returned in the select statement. So, if address is the first field name returned put address in the first label and company in the second label, and then the reverse if company in the first field name.

Here is the general idea.

Private Sub Form_Open(Cancel As Integer)
Dim rst As DAO.Recordset, indx as integer
Set rst = Me.Recordset

For indx = 0 To (rst.Fields.Count - 1)
' Debug.Print "field Names = "; rst.Fields(indx).Name
if rst.fields(0).name = "address" then
me.mylabeltext = "Address"
etc.........
Next '-- end for
End Sub
 
Wouldn't you want to shift the company name to the right?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top