473,326 Members | 2,126 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,326 software developers and data experts.

Field Name Count

I want to loop around the field names (fld1 - fld20) in a table
extracting the field name and using it to make changes to the status of
controls(lblFld1 - lblFld20) on a form.

e.g. I would like the code below to make the labels "lblFld1" -
"lblFld20" invisible on a form when the form is opened.

Private Sub Form_Open(Cancel As Integer)

Dim myDb As DAO.Database

Dim myRecs As DAO.Recordset

' Dim i As Integer

Dim fld As DAO.Field

Set myDb = CurrentDb
Set myRecs = myDb.OpenRecordset("tblName", db_Open_Table)
For Each fld In myRecs.Fields
me.controls("lbl" & myrecs.fields.name).visible = false
Next

End Sub

The error coming up says it is having a problem communicating with the
OLE Server or Active X control. There may be a problem evaluating
something or something doesn't exist. Please help as writing code for
each field will most likely cause my hands to drop off.

Thanks you in advance.

May 2 '06 #1
1 1429
mi********@hotmail.com wrote:
I want to loop around the field names (fld1 - fld20) in a table
extracting the field name and using it to make changes to the status of
controls(lblFld1 - lblFld20) on a form.

e.g. I would like the code below to make the labels "lblFld1" -
"lblFld20" invisible on a form when the form is opened.

Private Sub Form_Open(Cancel As Integer)

Dim myDb As DAO.Database

Dim myRecs As DAO.Recordset

' Dim i As Integer

Dim fld As DAO.Field

Set myDb = CurrentDb
Set myRecs = myDb.OpenRecordset("tblName", db_Open_Table)
For Each fld In myRecs.Fields
me.controls("lbl" & myrecs.fields.name).visible = false
Next

End Sub

The error coming up says it is having a problem communicating with the
OLE Server or Active X control. There may be a problem evaluating
something or something doesn't exist. Please help as writing code for
each field will most likely cause my hands to drop off.

Thanks you in advance.


Try:

me.controls("lbl" & fld.name).Properties("Visible") = false

James A. Fortune
CD********@FortuneJames.com

May 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
5
by: Theresa Hancock via AccessMonster.com | last post by:
I have an Excel table I need to import into Access. The name is entered into one field "Name". I'd like to have two fields in Access, FirstName and LastName. How do I do this. -- Message posted...
8
by: Bri | last post by:
Greetings, I am using Eval() in a query with only limited success. If the text within the function contains a reference to a Field I get #ERROR#. I'll try and explain what I'm trying to do and...
17
by: The Frog | last post by:
Hello everyone, I am working on an application that can build database objects in MS Access from text files. I suppose you could call it a backup and restore type routine. Accessing the...
7
by: p.lavarre | last post by:
How do I vary the byte offset of a field of a ctypes.Structure? How do I "use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by...
5
by: Genalube | last post by:
I am trying to count the number of owners that show up in a query (conveyQuery). The query will produce a column OwnName that will contain names like John Smith, Mike Jones, Frank Vaugn. Each of...
9
by: plumba | last post by:
Hi all I have a pretty cool script which, on the click of a button, sticks in a extra text box and gives it a unique name/id so it can be munipulated and sent through on a form. Problem is, I...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
0
by: wed1 | last post by:
Hi all I was asked from the company i support their intranet with asp to create a vb prog in order to retrive magazine circulations from their oracle server and update the number of circulations...
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...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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....

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.