Validation Rule Help: Option Group VS Text box

Okay, the problem appears to be that you manually typed in this part:

Private Sub Form_BeforeUpdate()

instead of letting Access put it in by selecting the dropdown and then clicking on the ellipsis to open to that event. What I did was to go to the VBA Window, select the whole SUB and then Cut it out and pasted to NOTEPAD. Then I go up to the dropdowns that are in the VBA Window, select FORM from the left one and then select BEFORE UPDATE from the one on the right. THEN paste the code I pasted into NOTEPAD in between the PRIVATE SUB ... and the END SUB parts, not including those for the other.

Also, you need to have is like this (instead of on one line for the IF):
Code:
    If Me.Xource = 1 And Len(Me.MMUID & "") = 0 Then
        Cancel = True
        MsgBox "You need to fill in the Student ID", vbExclamation, "Entry Error"
    End If
 
Okay, the problem appears to be that you manually typed in this part:

Private Sub Form_BeforeUpdate()

instead of letting Access put it in by selecting the dropdown and then clicking on the ellipsis to open to that event. What I did was to go to the VBA Window, select the whole SUB and then Cut it out and pasted to NOTEPAD. Then I go up to the dropdowns that are in the VBA Window, select FORM from the left one and then select BEFORE UPDATE from the one on the right. THEN paste the code I pasted into NOTEPAD in between the PRIVATE SUB ... and the END SUB parts, not including those for the other.

Also, you need to have is like this (instead of on one line for the IF):
Code:
    If Me.Xource = 1 And Len(Me.MMUID & "") = 0 Then
        Cancel = True
        MsgBox "You need to fill in the Student ID", vbExclamation, "Entry Error"
    End If

Thank you SOS

I followed your instruction... and yes the new record can now be added but it does not set ID field to be required when Xource=1...

would you be able to upload the file you successfully amended?
 
Actually, I think you may find that it does work. However it will not work on existing records because the Before Update event is not firing because nothing has been changed. Try starting from scratch by getting rid of any records you had to start with (or just try with a new record). If I try to add a new record it will not do so until the MMUID is filled out.

And by the way, if you had ZIPPED your file before trying to upload it here it would have done so. You may have done the Compact/Repair but you needed to zip the file and therefore it is WAY under the limit for uploading.
 

Attachments

Actually, I think you may find that it does work. However it will not work on existing records because the Before Update event is not firing because nothing has been changed. Try starting from scratch by getting rid of any records you had to start with (or just try with a new record). If I try to add a new record it will not do so until the MMUID is filled out.

And by the way, if you had ZIPPED your file before trying to upload it here it would have done so. You may have done the Compact/Repair but you needed to zip the file and therefore it is WAY under the limit for uploading.

Thank you SOS. You're my hero!
 

Users who are viewing this thread

Back
Top Bottom