By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

runtime error 2001 only when open tabbed form

jmoudy77
P: 20
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does DSum() not agree with the tabbed control?

I'm posting the code below.

Private Sub Form_Load()

ERROR STARTS HERE and continues to the next line if I remove the previous function.
DSumDay = DSum("[Day]", "StandsQ")

DSumNight = DSum("[Night]", "StandsQ")

DSumNVG = DSum("[NVG]", "StandsQ")

DSumHood = DSum("[Hood]", "StandsQ")

Text89 = DMax("[Date]", "StandsQ", "[STANDS Eval] = True")
Text90 = DMax("[Date]", "StandsQ", "[INST Eval] = True")
Text91 = DMax("[Date]", "StandsQ", "[NVG Eval] = True")
Text92 = DMax("[Date]", "StandsQ", "[NO NOTICE] = True")
Text93 = DMax("[Date]", "StandsQ", "[Table III/IV] = True")
Text94 = DMax("[Date]", "StandsQ", "[Table VII/VIII] = True")
Text95 = DMax("[Date]", "StandsQ", "[Table IX/X] = True")
SAEH = DMax("[Date]", "StandsQ", "[SAEH] = True")
FADEC = DMax("[Date]", "StandsQ", "[FADEC] = True")
CBAT = DMax("[Date]", "StandsQ", "[CBAT] = True")
CBRN = DMax("[Date]", "StandsQ", "[CBRN] = True")
[Last NVG] = DMax("[Date]", "StandsQ", "[NVG] > 0")
[Last Flt] = DMax("[Date]", "StandsQ")
Total = DSumDay + DSumNight + DSumNVG + DSumHood
[NVG Time] = DSumNVG
[PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
End Sub
Feb 3 '08 #1
Share this Question
Share on Google+
7 Replies


puppydogbuddy
Expert 100+
P: 1,923
I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does DSum() not agree with the tabbed control?

I'm posting the code below.

Private Sub Form_Load()

ERROR STARTS HERE and continues to the next line if I remove the previous function.
DSumDay = DSum("[Day]", "StandsQ")

DSumNight = DSum("[Night]", "StandsQ")

DSumNVG = DSum("[NVG]", "StandsQ")

DSumHood = DSum("[Hood]", "StandsQ")

Text89 = DMax("[Date]", "StandsQ", "[STANDS Eval] = True")
Text90 = DMax("[Date]", "StandsQ", "[INST Eval] = True")
Text91 = DMax("[Date]", "StandsQ", "[NVG Eval] = True")
Text92 = DMax("[Date]", "StandsQ", "[NO NOTICE] = True")
Text93 = DMax("[Date]", "StandsQ", "[Table III/IV] = True")
Text94 = DMax("[Date]", "StandsQ", "[Table VII/VIII] = True")
Text95 = DMax("[Date]", "StandsQ", "[Table IX/X] = True")
SAEH = DMax("[Date]", "StandsQ", "[SAEH] = True")
FADEC = DMax("[Date]", "StandsQ", "[FADEC] = True")
CBAT = DMax("[Date]", "StandsQ", "[CBAT] = True")
CBRN = DMax("[Date]", "StandsQ", "[CBRN] = True")
[Last NVG] = DMax("[Date]", "StandsQ", "[NVG] > 0")
[Last Flt] = DMax("[Date]", "StandsQ")
Total = DSumDay + DSumNight + DSumNVG + DSumHood
[NVG Time] = DSumNVG
[PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
End Sub
Day and Date are reserved words in ms access, and should not be used as field names. Try changing the names to something like MyDay and MyDate and see if that helps

Also, what is this? This is not proper syntax for the DSum function
Total = DSumDay + DSumNight + DSumNVG + DSumHood
[NVG Time] = DSumNVG
[PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
Feb 3 '08 #2

jmoudy77
P: 20
I cleaned up the Syntax a bit to try and fix the Day and Date issues and to eliminate comfusion.

I'm still getting the error when I try and open the form that has this form nested as a subform in a tab control.

I'm still not getting an error and everything works fine when I open the form directly. Here's the new code.


Private Sub Form_Load()

Dim DaySum As Integer
DaySum = DSum("[DayTime]", "StandsQ")
Dim NightSum As Integer
NightSum = DSum("[Night]", "StandsQ")
Dim NVGSum As Integer
NVGSum = DSum("[NVG]", "StandsQ")
Dim HoodSum As Integer
HoodSum = DSum("[Hood]", "StandsQ")

Stands = DMax("[FltDate]", "StandsQ", "[STANDS Eval] = True")
Inst = DMax("[FltDate]", "StandsQ", "[INST Eval] = True")
NVGEval = DMax("[FltDate]", "StandsQ", "[NVG Eval] = True")
NoNotice = DMax("[FltDate]", "StandsQ", "[NO NOTICE] = True")
TableIII = DMax("[FltDate]", "StandsQ", "[Table III/IV] = True")
TableVII = DMax("[FltDate]", "StandsQ", "[Table VII/VIII] = True")
TableIX = DMax("[FltDate]", "StandsQ", "[Table IX/X] = True")
SAEH = DMax("[FltDate]", "StandsQ", "[SAEH] = True")
FADEC = DMax("[FltDate]", "StandsQ", "[FADEC] = True")
CBAT = DMax("[FltDate]", "StandsQ", "[CBAT] = True")
CBRN = DMax("[FltDate]", "StandsQ", "[CBRN] = True")
[Last NVG] = DMax("[FltDate]", "StandsQ", "[NVG] > 0")
[Last Flt] = DMax("[FltDate]", "StandsQ")
Total = DaySum + NightSum + NVGSum + HoodSum
[NVG Time] = NVGSum
[PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")

End Sub
Feb 3 '08 #3

puppydogbuddy
Expert 100+
P: 1,923
I cleaned up the Syntax a bit to try and fix the Day and Date issues and to eliminate comfusion.

I'm still getting the error when I try and open the form that has this form nested as a subform in a tab control.

I'm still not getting an error and everything works fine when I open the form directly. Here's the new code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. Dim DaySum As Integer
  4. DaySum = DSum("[DayTime]", "StandsQ")
  5. Dim NightSum As Integer
  6. NightSum = DSum("[Night]", "StandsQ")
  7. Dim NVGSum As Integer
  8. NVGSum = DSum("[NVG]", "StandsQ")
  9. Dim HoodSum As Integer
  10. HoodSum = DSum("[Hood]", "StandsQ")
  11.  
  12.     Stands = DMax("[FltDate]", "StandsQ", "[STANDS Eval] = True")
  13.     Inst = DMax("[FltDate]", "StandsQ", "[INST Eval] = True")
  14.     NVGEval = DMax("[FltDate]", "StandsQ", "[NVG Eval] = True")
  15.     NoNotice = DMax("[FltDate]", "StandsQ", "[NO NOTICE] = True")
  16.     TableIII = DMax("[FltDate]", "StandsQ", "[Table III/IV] = True")
  17.     TableVII = DMax("[FltDate]", "StandsQ", "[Table VII/VIII] = True")
  18.     TableIX = DMax("[FltDate]", "StandsQ", "[Table IX/X] = True")
  19.     SAEH = DMax("[FltDate]", "StandsQ", "[SAEH] = True")
  20.     FADEC = DMax("[FltDate]", "StandsQ", "[FADEC] = True")
  21.     CBAT = DMax("[FltDate]", "StandsQ", "[CBAT] = True")
  22.     CBRN = DMax("[FltDate]", "StandsQ", "[CBRN] = True")
  23.     [Last NVG] = DMax("[FltDate]", "StandsQ", "[NVG] > 0")
  24.     [Last Flt] = DMax("[FltDate]", "StandsQ")
  25.     Total = DaySum + NightSum + NVGSum + HoodSum
  26.     [NVG Time] = NVGSum
  27.     [PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
  28.  
  29. End Sub
Your code looks much better.

Does your error occur whenever you click the tab control or does it occur just in the form load event without clicking the tab control? Have you set the master/child links between your main form and your subform?
Feb 3 '08 #4

jmoudy77
P: 20
The error occurs when the main form loads. I don't think it has anything to do with the tabbed control, because I created a new form to troubleshoot and added a subform with this form as its object source(no tabbed control).

I got the same error when I tried to open the new main form

Should there be any reason to use master/child linking between the main and subforms if I nothing but the subform on the main form?
Feb 3 '08 #5

puppydogbuddy
Expert 100+
P: 1,923
The error occurs when the main form loads. I don't think it has anything to do with the tabbed control, because I created a new form to troubleshoot and added a subform with this form as its object source(no tabbed control).

I got the same error when I tried to open the new main form

Should there be any reason to use master/child linking between the main and subforms if I nothing but the subform on the main form?
jmoudy,

Yes, there is. The master/child links (or code equivalent) are needed in order for the form/subform to work together in an organized fashion, If you have no controls on the main form, you can use the hidden textbox trick.

1. Place an unbound textbox named (for example) txtMasterLink on your main form. Set its control source to:= Forms!YourMain!YourSubformControl.Form!YourChildLi nkField.(the field that drives your subform)

2. Go to subform control on the border between the main form and the subform, invoke the property sheet, and put the following for master and child links.

Master Link: txtMasterLink
Child Link: the bound linkfield on your subform that corresponds to the master link
3. Test and see if it works. If it works ok, then you can set the visible property of txtMasterLink to False to hide it.
Feb 4 '08 #6

jmoudy77
P: 20
I recoded the form to pull info from the table rather than a query, that seemed to fix that problem.

The only issue I'm having with it now is that it won't allow me to navigate between records. It pulls the first record and then shows an empty record when next or prev record is selected.

BTW, I really appreciate the help.


Private Sub Form_Load()



[Stands] = DMax("[FltDate]", "Flight Data", "[STANDS Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[Inst] = DMax("[FltDate]", "Flight Data", "[INST Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[NVGEval] = DMax("[FltDate]", "Flight Data", "[NVG Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[NoNotice] = DMax("[FltDate]", "Flight Data", "[NO NOTICE] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[TableIII] = DMax("[FltDate]", "Flight Data", "[Table III/IV] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[TableVII] = DMax("[FltDate]", "Flight Data", "[Table VII/VIII] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[TableIX] = DMax("[FltDate]", "Flight Data", "[Table IX/X] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[SAEH] = DMax("[FltDate]", "Flight Data", "[SAEH] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[FADEC] = DMax("[FltDate]", "Flight Data", "[FADEC] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[CBRN] = DMax("[FltDate]", "Flight Data", "[CBRN] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[Last NVG] = DMax("[FltDate]", "Flight Data", "[NVG] > 0 And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[Last Flt] = DMax("[FltDate]", "Flight Data", "[FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[Total] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[NVG Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[NVG] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
[PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[PC] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")

End Sub
Feb 4 '08 #7

puppydogbuddy
Expert 100+
P: 1,923
I recoded the form to pull info from the table rather than a query, that seemed to fix that problem.

The only issue I'm having with it now is that it won't allow me to navigate between records. It pulls the first record and then shows an empty record when next or prev record is selected.

BTW, I really appreciate the help.
Check your form properties. Should be as follows:
allow additons = yes
allow edits = yes
data entry = no
Feb 4 '08 #8

Post your reply

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