473,467 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Continuous Form Question

60 New Member
I have a continuous form and a button in the header of the form. When I click the button, the following code is executed:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTest_Click()
  2.  
  3.     Dim objControl As Control
  4.  
  5.     For Each objControl In Me.Controls
  6.         If (objControl.ControlType = acTextBox) Then
  7.             Debug.Print objControl.Value
  8.         End If
  9.     Next
  10.  
  11. End Sub
  12.  
However, this code only returns the currently highlighted row of the continuous form.

Is there a way to either
  1. Access controls in a continuous form directly; OR
  2. Move the focus of the currently highlighted row within a continuous form
?
Jul 10 '08 #1
5 3310
fauxanadu
60 New Member
Here is a solution that does what is needed, although in a rather ugly way:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdTest_Click()
  2.  
  3.     Dim objControl As Control
  4.     Dim intRecordsLeft As Integer
  5.  
  6.     DoCmd.GoToRecord acDataForm, Me.Name, acLast
  7.     intRecordsLeft = Form.CurrentRecord
  8.  
  9.     DoCmd.GoToRecord acDataForm, Me.Name, acFirst
  10.  
  11.     While (intRecordsLeft)
  12.         For Each objControl In Me.Controls
  13.             If (objControl.ControlType = acTextBox) Then
  14.                 Debug.Print objControl.Value
  15.             End If
  16.         Next
  17.  
  18.         intRecordsLeft = intRecordsLeft - 1
  19.         If (intRecordsLeft > 0) Then 
  20.             DoCmd.GoToRecord acDataForm, Me.Name, acNext
  21.         End If
  22.     Wend
  23.  
  24. End Sub
  25.  
I still hope there is a better way though.
Jul 10 '08 #2
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I'm not clear what it is you want to do here; you seem to be traversing all records in your subform one by one for some reason - perhaps you could explain what it is you want to achieve?

In a continuous form there is ony the one set of controls, displayed repeatedly for each different record shown on the form. It is not possible to refer to controls on other records - Access does not set the continuous form up as an independent array of controls. When referring to such a control it is always the one for the current record which is accessed, and to change the record accessed you move the current record to another record (as you do in the code supplied in post 2).

If I knew what you wanted to do I could advise further on alternative approaches which might suit.

-Stewart
Jul 10 '08 #3
fauxanadu
60 New Member
There are about 100 forms I am going to impliment in a database. Each form has a save function. This save function will do the following:
  1. Loop through each control on the form
  2. When it finds a textbox or combo box, get the value
  3. Record the text/combo box value, the controls item number to the table
  4. Record the location of the control to the database (Was it on the main form or one of the subforms? If subform, which one?)

Once this is done, to restore the data for the form when a user selects a form that has already been filled out, the code would only have to determine which part of the form the info was on via the location data, and then simply loop through the data adding it back piece by piece.

The reason I am implimenting it this was is because the users need to be able to add forms with minimal effort at later dates.
Jul 11 '08 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. When you say 'add forms' do you mean 'add records'? Users are not really adding forms to your database are they?

I do not understand what is going on here, as unless your forms are unbound records entered in a data entry form in Access are saved automatically.

Sorry, but I don't think I have sufficient understanding of what it is you are doing to assist you.

-Stewart
Jul 11 '08 #5
fauxanadu
60 New Member
That's fine. I've found a reasonable, although not ideal, solution. Thank you for the attempt, however.

Just to clarify, yes, users will be adding forms to the database at a later date. I think the confusion comes from there being two different kinds of forms I am refering to. I tried to keep them distinct, but let me clarify.

First, there are forms that are database objects that users can interact with (the ones you are likely thinking of when I say forms). Second, there are paper forms that the users currently use. The solution is converting the paper forms into the digital forms so as to save input data for posterities sake and for various other reasons.

The paper forms change quite often and have new ones added and old ones removed quite often. Therefore the users need to be able to create revisions of the existing digital forms and create new digital forms entirely from scratch. I am trying to create a generic set of methods that will provide all the functionality required via VBA that is robust enough that they can simply copy a template and put the form elements where needed and not have to write a smidgeon of vba.

However, the normal method of data manipulation will not work, so I must create a different method. I've done this by using a few VBA methods to loop through all controls on a digital form, finding all textboxes and comboboxes (the fields users can change) and record their controls.item(number) number and value to the database, so the information can be retrieved later.

As stated before, thanks for taking the time to respond, but I think the solution I outlined above is workable if not perfect^.^
Jul 11 '08 #6

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

Similar topics

3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
3
by: Richard Hollenbeck | last post by:
I have the following query in my form's code: Private Function Get_Data(fieldNum As Integer) Dim strSQL As String Dim db As DAO.Database Dim rs As DAO.Recordset strSQL = "SELECT & "", "" & ...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
10
by: DFS | last post by:
I'm sure this has been discussed before, but I'm too tired to hunt for it. I have a survey table containing questions with different answer scales. Some are 1 to 5, others are A,B,C, etc. I show...
11
by: Doug Bell | last post by:
Hi, I am trying to create form that displays data like an Access continuous dataform rather than using a data grid. I am thinking that I can achieve this by creating a row of text boxes, one...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
2
by: bobh | last post by:
Hi All, In Access97 I have a form setup as a continuous form several of the bound controls have calculations that are done in the 'after update' event via VBA code and all works fine. My...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
3
by: trgpham | last post by:
Hi all, I have a question and really hoping you guys can help or point me to the right direction. MY SCENARIO: I need to design a screen which show up all the questionnaires and the users can...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.