|
-
Jul 21st, 2005, 08:33 AM
#1
Hide fields in Access
Is there a way to hide a field in a query?
IE) I have 15 different courses, each with a startdate and an enddate
The table goes as follows
ID Name Course1 SD1 ED1 Course2 SD2 ED2...etc
I only want to display certain courses, with their start and end dates, on a query if their course matches the one selected in a combobox.
example output (fields only) would be
ID Name Course3 SD1 ED1 Course 8 SD1 ED1...etc
For the record, I am really starting to hate Access
-
Jul 21st, 2005, 08:49 AM
#2
Re: Hide fields in Access
combobox/list box have column widths properties. Change to 0 to hide from view (still can access for reading through code though).
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 21st, 2005, 08:52 AM
#3
Re: Hide fields in Access
Sorry, I guess I was unclear.
I don't need to edit the combobox, the combobox is partly what I am basing my query off of. I only want to display the fields in my query that match the value in the combobox.
Thanks for trying, though.
-
Jul 21st, 2005, 10:13 AM
#4
Re: Hide fields in Access
What is your Sql statement?
Something like:
Code:
Select [table].[field1], [table].[field2]
From [table]
Where [table].[field1] = Forms!formname!controlname
Or use the query builder, select the table and fields you want, then in the criteria bit, right click and select Build. From here click the plus next to all forms, navigate to the form you want. The listbox the right of this fills with all the controls, select the control you want. The box next to that fills, and select text or value.
It should complete in the top part of the pop up window.
Click ok and it adds that to the query.
Hit the red exclamation mark to run (and test) - you'd need the form oopen and a value in the combo.
Edit
Your first post asked about hiding columns? Not filtering the table...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 21st, 2005, 10:21 AM
#5
Re: Hide fields in Access
It asked how to hide certain fields from the query based off data from my combobox.
And I know how to run a query, and have it display based off of the combobox..But I have 15 different courses, and I only want to display the 1 course which matches the entry in my combo box. So there are 14 other fields being hidden.
-
Jul 21st, 2005, 11:58 AM
#6
Re: Hide fields in Access
Maybe I am missing something but wouldnt you just not SELECT those fileds in your SELECT statement?
Make your SQL Statement dynamic.
So if they select course 2 and course 8 then the sql will look like this.
Code:
SELECT Course2, Course8 FROM Table1 WHERE SomeCriteria = SomeCriteriaValue;
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 21st, 2005, 12:04 PM
#7
Re: Hide fields in Access
well that would work, assuming each person in my table has the same course # in say, course1.
However, that is not the case. The table goes as such (before trimming)
Code:
ID Name Course1 SD1 ED1 Course2 SD2 ED2
40193885 Travis Smith 03032 11/02 12/25 04578 02/08 04/08
85903090 Joe Edwards 89305 04/08 11/11 85903 11/12 12/30
So if i grabbed all Course1's, then it wouldnt all be the same course
-
Jul 21st, 2005, 12:25 PM
#8
Re: Hide fields in Access
Well then you would need to Alias the fields so Course2 and Course8 would be...
Code:
SELECT Course2 As Course_1, Course8 As Course_2 FROM Table1 blah, blah, blah.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 21st, 2005, 12:31 PM
#9
Re: Hide fields in Access
okie, I will try that...But one more thing..I didn't think it was possible to use SQL in a query..is it?
and all this is being printed to a report..which is why I need the query... The query by default has all 15 courses listed (whether the ID has 15 courses or not), and I want to trim it down to 1
-
Jul 21st, 2005, 12:44 PM
#10
Re: Hide fields in Access
If the report is also in Access then you can late bind your report controls and in the report dynamically adjust which fileds or
header lable captions etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 21st, 2005, 01:06 PM
#11
Re: Hide fields in Access
i tried doing that before..But I don't know how to make my labels adjust to the amount of entries...there is always only the 1 label that i made myself
I just tried something like this to display only the ones I want..but this would only work for 1 record. It actually doesn't work because the textboxes are not enabled, so i cant set focus
VB Code:
Dim i As Integer
For i = 1 To 15
Me.Controls("Course" & i).SetFocus
If Me.Controls("Course" & i).Text = [Forms]![frmselect].cboSelectInfo.Value Then
Me.Controls("Course" & i).Visible = True
Else
Me.Controls("Course" & i).Visible = False
End If
Next
Last edited by kfcSmitty; Jul 21st, 2005 at 01:15 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|