Loop through a Control

How do I loop in a specific control using For?
The name of my Control is called "Result"
I am trying  the following with no luck, maybe because it is the end of the 
day?

Dim counter As Integer
counter = 0
Dim ctl As Control
For Each ctl In Me!Result
If IsNull(ctl) Then counter = counter + 1
Next ctl
If counter > 0 Then
MyText = MsgBox("Counters: " & counter, vbCritical, "Test")
End If

Thanks in advance 


0
Angel
9/25/2007 11:35:00 PM
access.formscoding 7493 articles. 0 followers. Follow

6 Replies
617 Views

Similar Articles

[PageSpeed] 26

Define "loop through a specific control".... it's not clear from your post 
what you want to achieve.
-- 

        Ken Snell
<MS ACCESS MVP>


"Angel G" <Nomail@please.com> wrote in message 
news:%23tHf7y8$HHA.5652@TK2MSFTNGP05.phx.gbl...
> How do I loop in a specific control using For?
> The name of my Control is called "Result"
> I am trying  the following with no luck, maybe because it is the end of 
> the day?
>
> Dim counter As Integer
> counter = 0
> Dim ctl As Control
> For Each ctl In Me!Result
> If IsNull(ctl) Then counter = counter + 1
> Next ctl
> If counter > 0 Then
> MyText = MsgBox("Counters: " & counter, vbCritical, "Test")
> End If
>
> Thanks in advance
> 


0
Ken
9/25/2007 11:45:25 PM
I have a subform that displays several records, but there is a specific 
control I would like to check for null values.
If all are null, I want to delete the records otherwise leave them as they 
are. So I am trying to use a FOR statement
See my code below.
Thanks


"Ken Snell (MVP)" <kthsneisllis9@ncoomcastt.renaetl> wrote in message 
news:OdaZg48$HHA.3848@TK2MSFTNGP05.phx.gbl...
> Define "loop through a specific control".... it's not clear from your post 
> what you want to achieve.
> -- 
>
>        Ken Snell
> <MS ACCESS MVP>
>
>
> "Angel G" <Nomail@please.com> wrote in message 
> news:%23tHf7y8$HHA.5652@TK2MSFTNGP05.phx.gbl...
>> How do I loop in a specific control using For?
>> The name of my Control is called "Result"
>> I am trying  the following with no luck, maybe because it is the end of 
>> the day?
>>
>> Dim counter As Integer
>> counter = 0
>> Dim ctl As Control
>> For Each ctl In Me!Result
>> If IsNull(ctl) Then counter = counter + 1
>> Next ctl
>> If counter > 0 Then
>> MyText = MsgBox("Counters: " & counter, vbCritical, "Test")
>> End If
>>
>> Thanks in advance
>>
>
> 


0
Angel
9/26/2007 2:32:43 AM
OK - you want to loop through the records and test the value of the control 
in each record.

Dim counter As Long
counter = 0
With Me.RecordsetClone
    .MoveFirst
    Do While .EOF = False
        counter = counter - IsNull(Me!Result.Value)
        .MoveNext
    Loop
End With
If counter > 0 Then MsgBox "Counters: " & counter, vbCritical, "Test"

-- 

        Ken Snell
<MS ACCESS MVP>




"Angel G" <Nomail@please.com> wrote in message 
news:elaRFW%23$HHA.1212@TK2MSFTNGP05.phx.gbl...
>I have a subform that displays several records, but there is a specific 
>control I would like to check for null values.
> If all are null, I want to delete the records otherwise leave them as they 
> are. So I am trying to use a FOR statement
> See my code below.
> Thanks
>
>
> "Ken Snell (MVP)" <kthsneisllis9@ncoomcastt.renaetl> wrote in message 
> news:OdaZg48$HHA.3848@TK2MSFTNGP05.phx.gbl...
>> Define "loop through a specific control".... it's not clear from your 
>> post what you want to achieve.
>> -- 
>>
>>        Ken Snell
>> <MS ACCESS MVP>
>>
>>
>> "Angel G" <Nomail@please.com> wrote in message 
>> news:%23tHf7y8$HHA.5652@TK2MSFTNGP05.phx.gbl...
>>> How do I loop in a specific control using For?
>>> The name of my Control is called "Result"
>>> I am trying  the following with no luck, maybe because it is the end of 
>>> the day?
>>>
>>> Dim counter As Integer
>>> counter = 0
>>> Dim ctl As Control
>>> For Each ctl In Me!Result
>>> If IsNull(ctl) Then counter = counter + 1
>>> Next ctl
>>> If counter > 0 Then
>>> MyText = MsgBox("Counters: " & counter, vbCritical, "Test")
>>> End If
>>>
>>> Thanks in advance
>>>
>>
>>
>
> 


0
Ken
9/26/2007 3:16:07 AM
Thank you!
Blessings to you Ken!


"Ken Snell (MVP)" <kthsneisllis9@ncoomcastt.renaetl> wrote in message 
news:e9F5Ou%23$HHA.4200@TK2MSFTNGP04.phx.gbl...
> OK - you want to loop through the records and test the value of the 
> control in each record.
>
> Dim counter As Long
> counter = 0
> With Me.RecordsetClone
>    .MoveFirst
>    Do While .EOF = False
>        counter = counter - IsNull(Me!Result.Value)
>        .MoveNext
>    Loop
> End With
> If counter > 0 Then MsgBox "Counters: " & counter, vbCritical, "Test"
>
> -- 
>
>        Ken Snell
> <MS ACCESS MVP>
>
>
>
>
> "Angel G" <Nomail@please.com> wrote in message 
> news:elaRFW%23$HHA.1212@TK2MSFTNGP05.phx.gbl...
>>I have a subform that displays several records, but there is a specific 
>>control I would like to check for null values.
>> If all are null, I want to delete the records otherwise leave them as 
>> they are. So I am trying to use a FOR statement
>> See my code below.
>> Thanks
>>
>>
>> "Ken Snell (MVP)" <kthsneisllis9@ncoomcastt.renaetl> wrote in message 
>> news:OdaZg48$HHA.3848@TK2MSFTNGP05.phx.gbl...
>>> Define "loop through a specific control".... it's not clear from your 
>>> post what you want to achieve.
>>> -- 
>>>
>>>        Ken Snell
>>> <MS ACCESS MVP>
>>>
>>>
>>> "Angel G" <Nomail@please.com> wrote in message 
>>> news:%23tHf7y8$HHA.5652@TK2MSFTNGP05.phx.gbl...
>>>> How do I loop in a specific control using For?
>>>> The name of my Control is called "Result"
>>>> I am trying  the following with no luck, maybe because it is the end of 
>>>> the day?
>>>>
>>>> Dim counter As Integer
>>>> counter = 0
>>>> Dim ctl As Control
>>>> For Each ctl In Me!Result
>>>> If IsNull(ctl) Then counter = counter + 1
>>>> Next ctl
>>>> If counter > 0 Then
>>>> MyText = MsgBox("Counters: " & counter, vbCritical, "Test")
>>>> End If
>>>>
>>>> Thanks in advance
>>>>
>>>
>>>
>>
>>
>
> 


0
Angel
9/26/2007 4:00:25 PM
You're welcome.

-- 

        Ken Snell
<MS ACCESS MVP>


"Angel G" <Nomail@please.com> wrote in message 
news:euwWcZFAIHA.968@TK2MSFTNGP03.phx.gbl...
> Thank you!
> Blessings to you Ken!
>


0
Ken
9/26/2007 4:12:39 PM
"Angel G" <Nomail@please.com> wrote in
news:elaRFW#$HHA.1212@TK2MSFTNGP05.phx.gbl: 

> I have a subform that displays several records, but there is a
> specific control I would like to check for null values.
> If all are null, I want to delete the records otherwise leave them
> as they are.

You don't want to loop through them at all. You want to execute a
SQL delete statement, which operates on a set of records. 

-- 
David W. Fenton                  http://www.dfenton.com/ 
usenet at dfenton dot com    http://www.dfenton.com/DFA/
0
David
9/27/2007 10:14:49 PM
Reply:

Similar Artilces:

Exchange 2003 - Corrupt header results in 1000's of emails
Hi, I have a problem, can anyone help? Setup is exchange 2003 on Small Business Server Inbound mail via POP3 connector. Outbound via SMTP. Messages are put into bad mail directory. Each message seems to have three files associated with it... 1. BDR file contains "Error is processing file in pickup directory." 2. BAD file seems to contain complete message body. 3. BDP file seems to contain message header. Message header contains multiple occurences of "@address.invalid," The message appears to loop and possibly also spawn additional copies. 1000's of copies of the e-m...

megacorps do not control
Rethink the Cool + the Shoe phil knight had a dream. he'd sell shoes. he'd sell dreams. he'd get rich. he'd use sweatshops if he had to. then along came a new shoe. plain. simple. cheap. fair. designed for only one thing: kicking phil's ass. the unswoosher $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ For years, Nike was the undisputed champion of logo culture, its swoosh an instant symbol of global cool. Today, Phil Knight's Nike is a fading empire, badly hurt by years of "brand damage" as activists and cu...

Control Msgbox position
I can not find a way to control where the msgbox pops up. My app requires multiple windows opened to reference other files and when the windows are tiled for best use onscreen, the msgbox always pops up in mid screen, instead of in the middle of the Access window. Anyone know a way in Access 03 to make the message box location relative to the Access window? -- Regards Larry "Larry" <Larry@discussions.microsoft.com> wrote in message news:78AAFC38-DA14-4813-8154-97DB231C9D89@microsoft.com... >I can not find a way to control where the msgbox pops up. &g...

Enable Cursor movement control in POS item entry
Please consider adding a configuration Control option in POS so during item entry it would stop on quantity or price instead of advancing to the next line. Our customer have just upgraded from QS2000 and had this option in the QS2000 and was very unhappy that this feature was taken out of RMS. It seems, that in an environment where items are scanned and the price and quantity are fixed it would make sense to have the cursor advance to the next line item, but in many environment price override and quantity entry now require the user to go back to the line above to make the changes. On...

Control using a Listbox
Hey, I have a form of records, and a listbox with all of the dates from said records. Anyone know a way to select one of the dates in the listbox and click a button to edit that record. I've tried findrecord and openform with that date as a filter but I always just get the first record shown. Also I have a report and was wondering if you knew how to make the selected record in the same listbox the last record displayed in the report, sort of like printing the week ending. Thanks The wizard doesn't build the criteria. You need to build it. Open the code module and provide a val...

Stuck in Advanced Start-up Options Reboot Loop
WinXP MCE When I booted my computer, I got an abbreviated Advanced Start-up menu: Safe Mode, SM with Networking, Last Known Good Config, and Start Windows Normally. None of these options work, and the computer just reboots right back into this menu. I've removed the hard drive and connected it to another working WinXP computer. I then ran chkdsk: r, AVG 9.0, Malwarebytes and everything is clean. Is there something else I can try, short of a reformat, to get this back up and running? All feedback is appreciated. Thanks! On Feb 17, 4:45=A0pm, "Dell Christ...

looping through columns and rows
Hello, Can someone show me the code which would allow me to search through a number of rows and columns, to identify a criteria. Each time the criteria is found, 1 is added to a variable. When the variable reaches a set number, the search moves to a different column. This would allow me to allocate people to jobs according to their first, second, third choice etc, without resourcing too many people to a job. can you help? I have very little experience, but am usually able to see what is happening in the code and expend on it to take care of more elements. kind regards, Matt Check one...

EVENT ID 3017
Hello All- We have just migrated mailboxes from an old Exchange 5.5 server to a new Exchange 2003 server (on Windows Standard Server 2003) and are getting the following message in the Application log on the new server: Event Type: Error Event Source: MSExchangeTransport Event Category: NDR Event ID: 3017 Date: 7/29/2005 Time: 7:24:40 AM User: N/A Computer: SAGEMSG Description: A non-delivery report with a status code of 5.3.5 was generated for recipient rfc822;deaduser@company.com (Message-ID <651706382-1463792126-1122606123@somedomain.com>). Causes: A looping condition was...

Looping through files
Hi, I am trying to loop through a directory of (.txt) files. What I would like to do is append the last 4 days (from today's date) worth of files into one file, and save that file for later processing. Does anyone know or have the logic that I need to process these files? Cheers, GT Use Dir to loop through the files in a folder. Here's a very simple example of appending them to an array: http://allenbrowne.com/func-02.html Use FileDateTime() to test if they are in the last 4 days; presumably you don't add the old ones to your array. I think you want to write the file ...

How to get proper tab sequence to controls
Hi to All, I am a newcomer. Query : how to assign proper tabbing order to controls. e.g. suppose i have 3 edit boxes in a row on a dialog. and while their creation, i have added them in the random order(e.g. 3,2,1). so when i run appln, n press tab, the tabbing order i expect is 1,2,3. how to resolve this? thanks in advance. kishor. I'm a newcomer, too... :-) Type a Ctrl+D command. You will see a set of numbered boxes pop up. You can click on the controls in the order you want them to be tabbed. Note that if you shift-click on an existing control, then you set the "current number...

Use a loop to create multiple Charts
I am running a loop in VBA which is supposed to draw a new chart fo every (2) column(s) of data. However, I am not sure how to make it "jump" from column to column. Part of my program (does not include the "For i=1 to3 e.t.c.) is below The *high-lighted *part is the part I am trying to change. Instead of fixed reference I wanted to get the data I have in th _underlined__part. Any suggestions??? Sheets("OUTPUT All data").Select _Range(Cells(11,_2_*_i),_Cells(11,_2_*_i_+_1)).Select_ Range(Selection, Selection.End(xlDown)).Select Charts.Add ActiveChart.ChartType ...

Active X control
Hi All, I am trying to make a dialog based ActiveX control in VC++ using MFC. I inserted buttons, radio buttons, and a FlexGrid control in this ActiveX. But when I run this control in a client application, the control disappears. If I remove Flexgrid, the control is displayed but when I press any button on this control, program hangs. Where is it that I might be going wrong? Would highly appreciate a solution or suggestion regarding this. TestHim wrote: > Hi All, > I am trying to make a dialog based ActiveX control in VC++ > using MFC. I inserted buttons, radio buttons, and ...

Slider Control with Floats
I would like to configure a Slider control for managing Floats. For example, I have a range which starts from 0.2 and ends at 11, with a 0.1 incremental value. As such, the series are (0.2, 0.3, 0.4, ..., 10.8, 10.9, 11) MFC Slider Control can only accept int values, any ideas on how to implement float values? >MFC Slider Control can only accept int values, any ideas on how to implement >float values? Scale the (integer) values appropriately (use a range of 2 to 110 in your example) and then convert to your FP value where you need it. Dave David is right. Here is an exampl...

Endless looping with Worksheet_change event (XL2003)
I have a data validation list on Sheet1. I have code that needs to trigger each time that cell selection is changed. No problem so far. When the value changes, I use that value to find corresponding records on sheet3, and copy them into Sheet1 in the desired columns. The base code seems to run pretty fast (when I run with breakpoints), but when I run the whole thing, the machine locks up and I get an 'out of memory' error. Is suspect it is because each time I paste in a cell value, this same sub (worksheet_change) is retriggered. Is there a way to temporarily block wo...

Using Groups in a virtual list control
Has anybody managed to get CListCtrl groups to work with a virtual list control? When I call EnableGroupView for a non-virtual list all is OK, but the minute I change it to owner data the call fails. Is it possible, the documentation (what there is of it) does not say that it is imposible. Gerard ...

changing the size and position of controls as the main dialog size changes
HI I am a beginner in VC++. I have created a simple dialog based program. I have placed an edit box in the dialog, what can I do so that as I change the size of the main dialog , the edit box size and position will also change in ratio with the main dialog Use MoveWindow Function lke this.. CRect rect; GetClientRect(rect); GetDlgItem(IDC_EDIT)->MoveWndow(0,0,rect.Width(),20); Cheers Tony "msnews.microsoft.com" <kwadowkwadow@yahoo.com> wrote in message news:OWX372YJGHA.1192@TK2MSFTNGP11.phx.gbl... > HI > > I am a beginner in VC++. I have created...

Activevx controls security settings keeps coming up in outlook exp
active x controls how do I set them so that i can stop the warning message apearing in outlook express isp windows proffessional xp Ask in an Outlook Express forum. This is an Microsoft Office Outlook forum. Outlook Express is family of Internet Explorer and Outlook of the Office family. Here is the link for the right forum http://communities.microsoft.com/newsgroups/default.asp?icp=InternetExplorer Good Luck! -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Service Pack 1 ----- &quo...

controls and res editor
Hello, I'm new to MFC programming for windows though I have read quite a bit about SDK and some MFC programming. My question is, I want to create a control (static text, etc.) to be a child window, not a dialog box. I want it to come up on program start in the main window as a child. MS Visual C++ 6.x Pro allows me to design a control in the resource editor. But it doesn't generate code to show or paint the control automatically. So I'm trying to figure where to insert such code. Would it be in the CMainFrame::OnCreate function ?? If so could you give me a brief example. D wrot...

How to change window style for a control
Welcome. They let's set up, that I have created the class CMyEdit : public CEdit and I have pointer to this class which is called m_pMyEdit. Now somewhere I would like evoke from outside m_pMyEdit->ModifyStyle(0, ES_MULTILINE, SWP_FRAMECHANGED) and after calling DWORD dwStyle = GetWindowLong(m_pMyEdit->m_hWnd, GWL_STYLE) a value of expression (dwStyle & ES_MULTILINE) == ES_MULTILINE is equal to true but some CMyEdit control still is in single line mode. Somebody can know as advise with this problem ? More thanks. promptfox@o2.pl ...

Delegating Control
Hi everyone, I'm running Exchange Server 2003 with about 12 Outlook 2003 clients and I want them to be able see when the other is available/free. I've found out that you can assign permissions to other users for accessing your personal folders by going into Options on each machine with Outlook 2003 and going to the delegates tab. My question is, how can I say who I want to be able what from my Exchange server? I figured that if I had 120 employess, it would be a huge pain to go physically to each machine control access permission, rather than just saying that "Sue is ...

How to update 'Edit Control' text from Timer Callback.
Hi, I need a way to update an Edit control control in MFC from a timer callback function. How can that be done as we cannot reference dialog box controls from callbacks? Even the following code gives me problems: VOID CALLBACK TimerProc ( HWND hParent, UINT uMsg, UINT uEventID, DWORD dwTimer ) { //Add the text CEdit *ptrtxtActivity; ptrtxtActivity = reinterpret_cast<CEdit *>(GetDlgItem(hParent,txtboxActivity)); ptrtxtActivity->SetWindowText(text); } Please let me know, Thank you, IdleBrain "IdleBrain" <indianmostwanted@yahoo.com> ha scritto nel messa...

XML - Xpath
Hello everyone, I contact this discussiongroup because I encountered a little problem with XSL. Let me explain it: I have following file "position.xml": <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="position.xsl"?> <data> <curve> <point>alfa</point> <point>beta</point> </curve> <curve> <point>gamma</point> <point>delta</point> </curve> </data> I have following file "position.xsl": <?xml ve...

user control of distro lists
I have set up some distro lists in AD. We have all 2003 servers and exchange 2003. I want to allow multiple users (if possible) to add and remove users to and from these lists. I saw a post already detailing this but I get no security tab on the dostro lists I created. I made the lists Universal and Distribution when I set them up. What do I need to do? Thanks. you need to view "advanced features" in your aduc console... -- Susan Conkey [MVP] "MikeB" <MikeB@discussions.microsoft.com> wrote in message news:2346AB31-9C7D-4761-8881-2D43475D68E5@microsoft....

Configuration XML, source control, diffing/comparing
We have a development MS CRM system where we test changes then export the customization to XML for importing on a production system. The XML file produced is put into source control so we can track changes to the system but the structure of the XML has extremely long lines that make it very difficult to do comparisions/diffs (we do this to make sure we are only making the intended changes and also to see what specifically changed in the configuration). Has anyone had to deal with this? You could easily write a quick .Net app that loaded the XML and applied standard formatting to it. ...

Header Control Notification question
Hi, I created a class called CMyHeaderCtrl which subclass the CHeaderCtrl class. I wish to handle the HDN_TRACK notification message. So I added the following code: MyHeaderCtrl.h: afx_msg void OnTrack(NMHDR *pNMHDR, LRESULT* pResult); MyHeaderCtrl.cpp: BEGIN_MESSAGE_MAP(CMyHeaderCtrl, CHeaderCtrl) //{{AFX_MSG_MAP(CMyHeaderCtrl) //}}AFX_MSG_MAP ON_NOTIFY_REFLECT(HDN_TRACK,OnTrack) END_MESSAGE_MAP() void CMyHeaderCtrl::OnTrack(NMHDR *pNMHDR, LRESULT* pResult) { AfxMessageBox("Track"); ... } The message is not shown when I try dragging the divider. However, if I change ON_N...