Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Dynamically Change the Listbox s Column Heads
Mubeezi Micah 

15 years ago
Dear Richard,

I am trying to dynamically change the listbox's column heads depending on whether the user is from Country X or Y. I am been successful except in a few SQL statements. I can't figure out why. Below is a sample code that works
If CurrentUserID = 14 Then s = " SELECT Missed2MonthsQ.PatientID, Missed2MonthsQ.TBMgtUnitNo, Missed2MonthsQ.RegDate, Missed2MonthsQ.PtName, Missed2MonthsQ.Sex, Missed2MonthsQ.Age, Missed2MonthsQ.County AS [District], Missed2MonthsQ.Payam AS [County], Missed2MonthsQ.Boma AS [Sub County], Missed2MonthsQ.Review2Date AS [Expected On], Missed2MonthsQ.TotalDays AS [Late], Missed2MonthsQ.NameOfPE, Missed2MonthsQ.Village, Missed2MonthsQ.NearestHF FROM Missed2MonthsQ WHERE (((Missed2MonthsQ.TotalDays)>0)) AND (((Missed2MonthsQ.TotalDays)< 120)); "
If CurrentUserID <> 14 Then s = " SELECT Missed2MonthsQ.PatientID, Missed2MonthsQ.TBMgtUnitNo, Missed2MonthsQ.RegDate, Missed2MonthsQ.PtName, Missed2MonthsQ.Sex, Missed2MonthsQ.Age, Missed2MonthsQ.County AS [County], Missed2MonthsQ.Payam AS [Payam], Missed2MonthsQ.Boma AS [Boma], Missed2MonthsQ.Review2Date AS [Expected On], Missed2MonthsQ.TotalDays AS [Late], Missed2MonthsQ.NameOfPE, Missed2MonthsQ.Village, Missed2MonthsQ.NearestHF FROM Missed2MonthsQ WHERE (((Missed2MonthsQ.TotalDays)>0)) AND (((Missed2MonthsQ.TotalDays)< 120)); "
  
PatientsNearBy.RowSource = s

And here is another that does not work (it populates the list box normally but the column heads do not change when CurrentUserID 14 signs in)!

If CurrentUserID = 14 Then s = " SELECT PeerEducatorsT.PeerEducatorID, PeerEducatorsT.NameOfPE, PeerEducatorsT.AgeOfPE, PeerEducatorsT.SexOfPE, PeerEducatorsT.CountyOfPE AS [District], PeerEducatorsT.PayamOfPE AS [County], PeerEducatorsT.BomaOfPE AS [Sub County], PeerEducatorsT.VillageOfPE, PeerEducatorsT.IsFormerTBPatient, PeerEducatorsT.PeerEducatorSince, PeerEducatorsT.TotalUnderCare, PeerEducatorsT.PhoneOfPE, PeerEducatorsT.HasBicyclePE, PeerEducatorsT.AltPhoneOfPE, PeerEducatorsT.NearestHF FROM PeerEducatorsT "
If CurrentUserID <> 14 Then s = " SELECT PeerEducatorsT.PeerEducatorID, PeerEducatorsT.NameOfPE, PeerEducatorsT.AgeOfPE, PeerEducatorsT.SexOfPE, PeerEducatorsT.CountyOfPE AS [County], PeerEducatorsT.PayamOfPE AS [Payam], PeerEducatorsT.BomaOfPE AS [Boma], PeerEducatorsT.VillageOfPE, PeerEducatorsT.IsFormerTBPatient, PeerEducatorsT.PeerEducatorSince, PeerEducatorsT.TotalUnderCare, PeerEducatorsT.PhoneOfPE, PeerEducatorsT.HasBicyclePE, PeerEducatorsT.AltPhoneOfPE, PeerEducatorsT.NearestHF FROM PeerEducatorsT "

If W <> "" Then
    s = s & " WHERE " & W
End If
s = s & " ORDER BY TotalUnderCare DESC;"
NameSearchList.RowSource = s

Where i am i going wrong? All the SQL statements related to PeerEducatorsT do not seem to change the column heads dynamically. Is it the table which may have a problem?

Please advice me

Best regards,

MICAH

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/24/2026 3:11:54 PM. PLT: 0s