473,394 Members | 1,965 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,394 software developers and data experts.

Do Loop provides incomplete data

I have a Do-Loop routine that checks the values of certain fields in a
Form (F_OmissionCheck) for omissions. If the field is blank, the
strOmissions variable is modified with additional verbiage that will
later be displayed to the user via a MsgBox. Since there may be more
than one record that needs to be checked, this routine is repeated for
however many records are returned in the underlying query/form.

The problem is when I run the routine, the resulting MsgBox
(strOmissions) only displays the omissions recorded for the first
record, even if there are omissions in the 2nd record (or 3rd...).
The strange thing is, when I hit the command button that runs this
routing a couple of more times, I keep getting the same incomplete
response, UNLESS I wait 5 or 10 seconds before hitting the command
button again. If I wait this short period before re-running this
routine, the MsgBox correctly appears with all the omissions
documented even for the 2nd or 3rd records. The same code seems to
be producing different results depending on how long I wait before
running the routine. I've tried Refresh and RunQuery, but that
didn't appear to do anything.
MsgBox results first try:
Start of List
Bay#1: Controller: Split or Common...
Bay#1: Controller: Voltage Sensing...
End of List

MsgBox results if I repeat the routine after waiting a short period:
Start of List
Bay#1: Controller: Split or Common...
Bay#1: Controller: Voltage Sensing...
Bay#2: Switch Operator: Control Power...
End of List

Any suggestions on how to resolve this would be apprecieated.
Code is below....
Private Sub InitiateComputerCheck_Click()
Rem The following Code generates a list of omissions that must be
resolved prior to the Design Request being submitted to MEGPD
Dim strOmissions As String
Dim recCheck As Integer
Dim recCount As Integer
Dim recCurrent As Integer
recCurrent = 1
OKtoProceed = "No"
strOmissions = "Start Of List"
DoCmd.OpenForm "F_OmissionCheck", acNormal, , , acFormReadOnly,
acHidden
DoCmd.GoToRecord acForm, "F_OmissionCheck", acFirst
'Start checking for omissions in key data fields
recCount = Forms![F_OmissionCheck].Recordset.RecordCount
Do
A: If Forms![F_OmissionCheck].[Controller] <> "None" Then GoTo A1 Else
GoTo B
A1: Select Case Forms![F_OmissionCheck].[SplitCommon]
Case "00" To "zz"
GoTo A2 ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Split or
Common Bus Scheme"
End Select
A2: Select Case Forms![F_OmissionCheck].[VoltageSensing]
Case "00" To "zz"
GoTo A3 ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Voltage
Sensing"
End Select
A3: Select Case
Forms![F_OmissionCheck].[ControlPower_Controller]
Case "00" To "zz"
GoTo B ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Control
Power"
End Select
B: If Forms![F_OmissionCheck].[SwitchOperator] <> "None" Then GoTo B1
Else GoTo C
B1: Select Case Forms![F_OmissionCheck].[OperatorPowerSource]
Case "00" To "zz"
GoTo C ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Switch Operator:
Control Power"
End Select
C:
If recCurrent = recCount Then Exit Do
recCurrent = recCurrent + 1
DoCmd.GoToRecord acForm, "F_OmissionCheck", acNext
recCheck = Forms![F_OmissionCheck].CurrentRecord
Loop
Rem -----------------------------------------------------------------------------
If strOmissions = "" Then OKtoProceed = "YES" Else GoTo ShowOmissions
MsgBox "There are no major omissions detected. You can proceed
to submit the Design Request Form"
GoTo EndSub
ShowOmissions:
strOmissions = strOmissions & Chr(13) & "End of List"
OKtoProceed = "No"
MsgBox strOmissions, vbOKOnly, "The following major omissions have
been detected:"
MsgBox "You need to provide the missing data prior to submitting the
Design Request to MEGPD"

EndSub: End Sub
Nov 12 '05 #1
1 1676
Doug wrote:
I have a Do-Loop routine that checks the values of certain fields in a
Form (F_OmissionCheck) for omissions. If the field is blank, the
strOmissions variable is modified with additional verbiage that will
later be displayed to the user via a MsgBox. Since there may be more
than one record that needs to be checked, this routine is repeated for
however many records are returned in the underlying query/form.

The problem is when I run the routine, the resulting MsgBox
(strOmissions) only displays the omissions recorded for the first
record, even if there are omissions in the 2nd record (or 3rd...).
The strange thing is, when I hit the command button that runs this
routing a couple of more times, I keep getting the same incomplete
response, UNLESS I wait 5 or 10 seconds before hitting the command
button again. If I wait this short period before re-running this
routine, the MsgBox correctly appears with all the omissions
documented even for the 2nd or 3rd records. The same code seems to
be producing different results depending on how long I wait before
running the routine. I've tried Refresh and RunQuery, but that
didn't appear to do anything.
MsgBox results first try:
Start of List
Bay#1: Controller: Split or Common...
Bay#1: Controller: Voltage Sensing...
End of List

MsgBox results if I repeat the routine after waiting a short period:
Start of List
Bay#1: Controller: Split or Common...
Bay#1: Controller: Voltage Sensing...
Bay#2: Switch Operator: Control Power...
End of List

Any suggestions on how to resolve this would be apprecieated.
Code is below....
Private Sub InitiateComputerCheck_Click()
Rem The following Code generates a list of omissions that must be
resolved prior to the Design Request being submitted to MEGPD
Dim strOmissions As String
Dim recCheck As Integer
Dim recCount As Integer
Dim recCurrent As Integer
recCurrent = 1
OKtoProceed = "No"
strOmissions = "Start Of List"
DoCmd.OpenForm "F_OmissionCheck", acNormal, , , acFormReadOnly,
acHidden
DoCmd.GoToRecord acForm, "F_OmissionCheck", acFirst
'Start checking for omissions in key data fields
recCount = Forms![F_OmissionCheck].Recordset.RecordCount
Do
A: If Forms![F_OmissionCheck].[Controller] <> "None" Then GoTo A1 Else
GoTo B
A1: Select Case Forms![F_OmissionCheck].[SplitCommon]
Case "00" To "zz"
GoTo A2 ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Split or
Common Bus Scheme"
End Select
A2: Select Case Forms![F_OmissionCheck].[VoltageSensing]
Case "00" To "zz"
GoTo A3 ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Voltage
Sensing"
End Select
A3: Select Case
Forms![F_OmissionCheck].[ControlPower_Controller]
Case "00" To "zz"
GoTo B ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Controller: Control
Power"
End Select
B: If Forms![F_OmissionCheck].[SwitchOperator] <> "None" Then GoTo B1
Else GoTo C
B1: Select Case Forms![F_OmissionCheck].[OperatorPowerSource]
Case "00" To "zz"
GoTo C ' something is in this field
Case Else: strOmissions = strOmissions & Chr(13) & "Bay #: " &
Forms![F_OmissionCheck].Form![BayNumber] & " " & "Switch Operator:
Control Power"
End Select
C:
If recCurrent = recCount Then Exit Do
recCurrent = recCurrent + 1
DoCmd.GoToRecord acForm, "F_OmissionCheck", acNext
recCheck = Forms![F_OmissionCheck].CurrentRecord
Loop
Rem -----------------------------------------------------------------------------
If strOmissions = "" Then OKtoProceed = "YES" Else GoTo ShowOmissions
MsgBox "There are no major omissions detected. You can proceed
to submit the Design Request Form"
GoTo EndSub
ShowOmissions:
strOmissions = strOmissions & Chr(13) & "End of List"
OKtoProceed = "No"
MsgBox strOmissions, vbOKOnly, "The following major omissions have
been detected:"
MsgBox "You need to provide the missing data prior to submitting the
Design Request to MEGPD"

EndSub: End Sub


I have no idea why you bother to open the form when you basically hide it when
opened.

If it were me designing the code. I'd simply take the recordsource and open it in a
recordset.

I really didn't study your code. But if it were me and I was using your method of
opening the form I'd have a routine in the OnOpen event perhaps that would be
something like

If Me.OpenArgs = "Hidden" Then
'pass the word "Hidden" if opening the form not visible
Dim rst As Recordset

Set rst = Me.recordsetclone
If rst.RecordCount > 0 then
rst.MoveFirst
Do While Not rst.Eof
.....process
rst.MoveNext
Loop
msgbox "Results...."
Else
msgbox "Nothing to report"
endif
Cancel = True
Endif
Nov 12 '05 #2

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

Similar topics

20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
5
by: Paul F. Dietz | last post by:
Is the following legal C? struct foo; struct foo (*p); /* Pointer to array of 10 foo structures */ struct foo { int bar; int baz; }; main() { printf("%d\n", sizeof(*p)); } Paul Dietz...
24
by: ark | last post by:
Hello group, Could you help me with this: static const int x; ............ something ............. static const int x = 17; It looks perfectly legal to me but MSVC/C++ 6.0 gives, on the...
4
by: CMW | last post by:
In VB.NET I'm retrieving a single table from a SQL Server (tblformdata). I need to search each record in the dataset to see if any data is missing from the records (i.e., missing first name,...
1
by: Christopher DeMarco | last post by:
Hi all... I've written a class to provide an interface to popen; I've included the actual select() loop below. I'm finding that "sometimes" popen'd processes take "a really long time" to...
2
by: Jan | last post by:
In a 2-page order form, not all applicants will complete it due to field validations. If I want to see data from incomplete orders, can this be done using some sort of session control so that each...
1
by: AJ Smith | last post by:
To Whom It May Concern: I have the following code: #include <cctype> //Provides isdigit #include <cstdlib> //Provides EXIT_SUCCESS #include <cstring> //Provides strchr #include <iostream>...
5
by: vippstar | last post by:
Hello comp.lang.c I had to write a for() loop with two temporary variables for it. What I *usually* do is define the variables at the top so it works in C89 as well. But I realized that it just...
50
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.