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!

Displaying fields

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Is there a way that I can only display fields if they meet the criteria.

eg.

I have criteria that could be in 1 of 12 fields but on query/report only want to show the field that matches the criteria not all 12. Each record may have the criteria in a different one of these 12 fields.

Any suggestions
 
Hmmm, honestly, it sounds like you may want to re-evaluate your table design. 12 different fields??

Of course, without having seen your table structure I can't offer any good advice there. However, I have used a trick in my reports which may work for you.

Place all 12 textboxes on the report in the same spot. (Just stack 'em all on top of one another, Access won't mind) and set the visible property to false for all 12. Then in the on_format event write a Case statement (see Access Help for proper syntax) and use it to turn the appropiate box to visible = true. Maq B-)
<insert witty signature here>
 
Hi,

If your question is referring to a report or form then Yes
otherwise No see belwo for an example :

1) I am assuming you have an input for the search and this value is stored in a Text box, txtSchCrt, on the Report or Form then if you have the following Code in the

OnOPenEvent :

Me![Field1].Visible = False
Me![Field2].Visible = False
etc.

AfterUpdateEvent :

If Me![Field1]=TxtSchCrt then
Me![Field1].visible=true
End If
If Me![Field2]=TxtSchCrt then
Me![Field2].visible=true
End If
etc.

Unless your search is done through code to create the SQL string for a query then you will also be able to apply your search criteria to a query.



If you have any further queries please do not hesitate to ask.

HoleInTheFoot
 
Thanks for help.

Concerning the advice from HoleintheFoot. My criteria is in the query (not as text box) as it is static. On my form I do not have an AfterupdateEvent.

Where can I put the code?
 
The simplest method is place an unbound text box on the form and populate it with the appropriate field which meets the criteria.

Select Case textbox
Case field1
Textbox = field1
Case field2
Textbox = field2
etc......
End Select

mac
 
The simplest method is place an unbound text box on the form\report and populate it with the appropriate field which meets the criteria.

Select Case textbox
Case field1
Textbox = field1
Case field2
Textbox = field2
etc......
End Select

mac
 
Hi again,

The AfterUpdate Event is behind the text box &quot;TxtSchCrt&quot;.

However you have indicated your criteria is in the query, please can you send me a copy of the SQL string for me to access if a different solution is poss.

HoleInTheFoot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top