If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Validation of subform
I have created a form and wish to validate entries within the form and a
subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#2
|
|||
|
|||
Validation of subform
If you are saying that you'd like Access to check on the record you are
entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#3
|
|||
|
|||
Validation of subform
If the validation is taking place when a user clicks a button on the parent
form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#4
|
|||
|
|||
Validation of subform
I take it you are saying that I should have some over event (On Lost Focus)
trigger the validation of the subform and only validate the parent form when they click the button to exit the record. "Bob Larson" wrote: You have to realize that each is a separate action. If you move from the main form to the subform, changes on the main form are saved first and then you are on the subform. Similarly when you move back to the main form from the subform, your subform changes are saved before you are actually on the main form again. If you validate subform entries on the main form then you can't cancel the updates of the subform as they have already happened. If the validation failed then you would need to remove the subform entry with a delete query. -- Thanks, Bob Larson Access MVP Administrator, Access World Forums Utter Access VIP Free Access Tutorials and Resources: http://www.btabdevelopment.com "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#5
|
|||
|
|||
Validation of subform
If you are using a standard main form/subform construction, there is NO
activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#6
|
|||
|
|||
Validation of subform
There is data in both the form and subform which must be validated before a
record is considered complete enough to be entered into the database. I had this as two separate input forms, but the client didn't like that approach. "Jeff Boyce" wrote: If you are using a standard main form/subform construction, there is NO activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#7
|
|||
|
|||
Validation of subform
As I mentioned, standard Access main form/subform construction requires a
record in the main form before a subform record can be entered. I still don't have enough information to tell if your main form/subform is standard. One advantage to using the standard approach is that you can validate the main form's record (i.e., the "one" side of a one-to-many relationship) before attempting to add a subform record (the "many" side). Of course, this assumes that your data is well-normalized and organized in a pair of tables related one-to-many. Is this a fair assumption? (still) More information, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... There is data in both the form and subform which must be validated before a record is considered complete enough to be entered into the database. I had this as two separate input forms, but the client didn't like that approach. "Jeff Boyce" wrote: If you are using a standard main form/subform construction, there is NO activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#8
|
|||
|
|||
Validation of subform
The main form contains general information related to each record (the one).
The subform contains information at a lower level (the many). The main form must contain items such as routing number, title, and source to be considered a record. If any of these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the form. The subform must contain items related to the "steps" taken such as action plan and estimated completion date. If these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the subform. My thought was to have the entire form/subform validated, when the user clicks a button (Save & Close). Right now only the parent is validated. I tried adding validation and referencing the subform within the parent, but I get a messaging saying it can't find the form (subform). If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Deficiency Source] = 'SCAMPI' and [Forms]![frmOther Weakness Corrective Actions (New Entry)]![ProcessAreas] is Null")) Then MsgBox "A Value for 'Process Area' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for the weakness ' Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Status] is Null")) Then MsgBox "A Value for 'Status' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![Other Corrective Action Plan subform1]![CorrectiveActionPlanItem] is Not Null and [Forms]![Other Corrective Action Plan subform1]![OCD] is Null")) Then MsgBox "A Value for 'Corrective Action Plan Estimated Completion Date.", vbOKOnly, "Required Value Missing" intIsError = 1 End If "Jeff Boyce" wrote: As I mentioned, standard Access main form/subform construction requires a record in the main form before a subform record can be entered. I still don't have enough information to tell if your main form/subform is standard. One advantage to using the standard approach is that you can validate the main form's record (i.e., the "one" side of a one-to-many relationship) before attempting to add a subform record (the "many" side). Of course, this assumes that your data is well-normalized and organized in a pair of tables related one-to-many. Is this a fair assumption? (still) More information, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... There is data in both the form and subform which must be validated before a record is considered complete enough to be entered into the database. I had this as two separate input forms, but the client didn't like that approach. "Jeff Boyce" wrote: If you are using a standard main form/subform construction, there is NO activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#9
|
|||
|
|||
Validation of subform
You mention trying to do the validation from the parent form. It seems
you've already decided "how". Take a look at "expressions" in Access HELP for a way to refer to controls on a subform. (and I still believe you'd have more luck if you'd set up the validation of the subform data IN the subform itself). Good luck! Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... The main form contains general information related to each record (the one). The subform contains information at a lower level (the many). The main form must contain items such as routing number, title, and source to be considered a record. If any of these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the form. The subform must contain items related to the "steps" taken such as action plan and estimated completion date. If these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the subform. My thought was to have the entire form/subform validated, when the user clicks a button (Save & Close). Right now only the parent is validated. I tried adding validation and referencing the subform within the parent, but I get a messaging saying it can't find the form (subform). If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Deficiency Source] = 'SCAMPI' and [Forms]![frmOther Weakness Corrective Actions (New Entry)]![ProcessAreas] is Null")) Then MsgBox "A Value for 'Process Area' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for the weakness ' Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Status] is Null")) Then MsgBox "A Value for 'Status' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![Other Corrective Action Plan subform1]![CorrectiveActionPlanItem] is Not Null and [Forms]![Other Corrective Action Plan subform1]![OCD] is Null")) Then MsgBox "A Value for 'Corrective Action Plan Estimated Completion Date.", vbOKOnly, "Required Value Missing" intIsError = 1 End If "Jeff Boyce" wrote: As I mentioned, standard Access main form/subform construction requires a record in the main form before a subform record can be entered. I still don't have enough information to tell if your main form/subform is standard. One advantage to using the standard approach is that you can validate the main form's record (i.e., the "one" side of a one-to-many relationship) before attempting to add a subform record (the "many" side). Of course, this assumes that your data is well-normalized and organized in a pair of tables related one-to-many. Is this a fair assumption? (still) More information, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... There is data in both the form and subform which must be validated before a record is considered complete enough to be entered into the database. I had this as two separate input forms, but the client didn't like that approach. "Jeff Boyce" wrote: If you are using a standard main form/subform construction, there is NO activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
#10
|
|||
|
|||
Validation of subform
I tried setting up the validation within the subform without any luck.
Perhaps my approach was wrong. I tried using the On Close, the On Lost Focus, Got Focus, and the After Update for a specific control to trigger the validation of the subform. Private Sub Form_GotFocus() If (Eval("[Forms]![Other Corrective Action Plan subform1]![OCD] Is Null")) Then MsgBox "A Value for 'Corrective Action Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" End Sub "Jeff Boyce" wrote: You mention trying to do the validation from the parent form. It seems you've already decided "how". Take a look at "expressions" in Access HELP for a way to refer to controls on a subform. (and I still believe you'd have more luck if you'd set up the validation of the subform data IN the subform itself). Good luck! Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... The main form contains general information related to each record (the one). The subform contains information at a lower level (the many). The main form must contain items such as routing number, title, and source to be considered a record. If any of these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the form. The subform must contain items related to the "steps" taken such as action plan and estimated completion date. If these are Null, I want the user to enter a value before they are allowed to save the data to the database and close the subform. My thought was to have the entire form/subform validated, when the user clicks a button (Save & Close). Right now only the parent is validated. I tried adding validation and referencing the subform within the parent, but I get a messaging saying it can't find the form (subform). If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Deficiency Source] = 'SCAMPI' and [Forms]![frmOther Weakness Corrective Actions (New Entry)]![ProcessAreas] is Null")) Then MsgBox "A Value for 'Process Area' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for the weakness ' Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![Status] is Null")) Then MsgBox "A Value for 'Status' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If If (Eval("[Forms]![Other Corrective Action Plan subform1]![CorrectiveActionPlanItem] is Not Null and [Forms]![Other Corrective Action Plan subform1]![OCD] is Null")) Then MsgBox "A Value for 'Corrective Action Plan Estimated Completion Date.", vbOKOnly, "Required Value Missing" intIsError = 1 End If "Jeff Boyce" wrote: As I mentioned, standard Access main form/subform construction requires a record in the main form before a subform record can be entered. I still don't have enough information to tell if your main form/subform is standard. One advantage to using the standard approach is that you can validate the main form's record (i.e., the "one" side of a one-to-many relationship) before attempting to add a subform record (the "many" side). Of course, this assumes that your data is well-normalized and organized in a pair of tables related one-to-many. Is this a fair assumption? (still) More information, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... There is data in both the form and subform which must be validated before a record is considered complete enough to be entered into the database. I had this as two separate input forms, but the client didn't like that approach. "Jeff Boyce" wrote: If you are using a standard main form/subform construction, there is NO activity in the form that is your subform UNTIL it gets the focus. Why would you be clicking a button in the main form when its data entered in the subform that needs validation? More info, please... Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... If the validation is taking place when a user clicks a button on the parent form, how would putting the code on the subform be executed? "Jeff Boyce" wrote: If you are saying that you'd like Access to check on the record you are entering in a subform, have you tried putting your validation code in that subform (*actually, you'd put it in the form you are using as a subform*)? Regards Jeff Boyce Microsoft Office/Access MVP "dsc2bjn" wrote in message ... I have created a form and wish to validate entries within the form and a subform. I have placed the form validation code as part of the "Close" button. Example: If (Eval("[Forms]![frmOther Weakness Corrective Actions (New Entry)]![OCD] is Null")) Then MsgBox "A Value for 'Estimated Completion Date' is Required.", vbOKOnly, "Required Value Missing" intIsError = 1 End If I now wish to validate entries on the subform. I tried calling the "[subForm]", but get an error saying basically the method does not exist. How can I validate the subform entries? Also, I wish to spell check the form and subform. I can spell check the form, but the subform is ignored. Dim ctlSpell As Control Dim frm As Form Set frm = Screen.ActiveForm DoCmd.SetWarnings False For Each ctlSpell In frm.Controls If TypeOf ctlSpell Is TextBox Then If Len(ctlSpell) 0 Then With ctlSpell 'only spell check the text boxes with a value of true in their tag property. If .Tag = "True" Then .SetFocus .SelStart = 0 .SelLength = Len(ctlSpell) DoCmd.RunCommand acCmdSpelling End If End With End If End If Next MsgBox "Spell check complete.", vbInformation + vbOKOnly, "Finished." DoCmd.SetWarnings True DoCmd.Close End If |
|
Thread Tools | |
Display Modes | |
|
|