473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

how can I add or remove fields

18
Hi,

I have a Form and SubFrom in MS Access 2007 , the SubForm default view is “Datasheet”

Now, after I run the main Form with the imbedded SubForm , how can I add or remove fields form the SubFrom using VB ( adding and removing fields will be controlled from the main Form)

Your help is highly appreciated.
Dec 14 '09 #1
2 2923
hjozinovic
167 100+
hi Busbait,

You probably want to be able to show/hide columns on your subform.
To do this you could use a code like this:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2. Dim ctlName As String
  3. Private Sub Combo5_Enter()
  4. Me!Combo5.RowSource = ""
  5. For Each ctl In Me!sfTable1.Form.Controls
  6. If ctl.ControlType = acTextBox Then
  7. Me!Combo5.AddItem ctl.Name
  8. End If
  9. Next ctl
  10. End Sub
  11.  
  12. Private Sub btnHide_Click()
  13. ctlName = Me!Combo5
  14. Set ctl = Me!sfTable1.Form.Controls(ctlName)
  15. ctl.ColumnHidden = True
  16. End Sub
This is something I just tested and it works great.
I have a comboBox on the main form.
It lists all the columns from your subform.
After you select one from the list, you would click on btnHide to hide the column.
This should get you on th right track.
regards, h.
Dec 14 '09 #2
Busbait
18
Thanks ....... hjozinovic

It works fine
Dec 15 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: u7djo | last post by:
Hi, I'm currently building an application in Access and as part of this need to import forms and modules from another database. Some of the imports will be revisions of existing forms/modules so I...
2
by: deko | last post by:
I have an import routine that massages data from tables imported from other Access MDB's. I came across one table where the imported table contained Lookup fields - my import code barfed on it. ...
1
by: Rolan | last post by:
I need to be able to remove <BR>'s that are placed in null fields (Access 97) for blank records when doing html imports. Of course, Access does not recognize the html tags and are invisible. Aside...
7
by: No Spam | last post by:
Dear Access 2003 users, Can anyone assist me with creating either code (preferred) or a query that would remove a single field (called ID) from a table? And as a bonus question, can anyone...
0
by: aredo3604gif | last post by:
I have coded a serie of singly linked lists in ANSI C which I have to use. The lists are then stored in a serie of buckets with chained hash table technique. In the various lists there are nodes...
2
by: rics | last post by:
Hello, I have a form with basicly three fields, as follows: NAME PHONE_TYPE - PHONE_NUMBER The second line have two fields. I have to do something to allow the
1
by: UKuser | last post by:
How can I remove a div with a known name/id within javascript? The reason I need to do this, is I have a div called <div id='test'> which displays some database fields. AJAX/PHP/MYSQL updates the...
1
by: Neekos | last post by:
I have a report that shows information for up to 5 passengers per booking. Not every booking has all 5 passengers in it, so i dont want those fields showing up on my report. How can i get rid of...
2
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.