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
|
|||
|
|||
VB Coding Assistance
I am a novice coder trying to learn VB OJT and I am getting no where. I have
a form that the client enters data to go onto the table. I always want the client to enter certain pieces of data then I validate it through VB code. My problem right now is that I have made the form dirty and then have a procedure that occurs beforeupdate event. If the client clicks on the Cancel and Exit button without saving, I get a message that the client must enter the user. On clicking on 'OK' it exits as it should but I cannot get it to quit that display of the msgbox. The click on the Cancel runs this code. Private Sub Command56_Click() DoCmd.CancelEvent DoCmd.Close End Sub and the Before update runs this code. Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Err_BUForm_Click If IsNull(Me.User) Then MsgBox "Please Enter a Specialistbu." Me.User.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.AttendDate) Then MsgBox "Please Enter a valid Datebu." Me.AttendDate.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.Comments) Then MsgBox "Please Enter Commentsbu." Me.Comments.SetFocus Cancel = True GoTo Exit_BUForm_Click End If Exit_BUForm_Click: Exit Sub Err_BUForm_Click: MsgBox Err.Description Resume Exit_BUForm_Click End Sub Any suggestions will be appreciated greatly! |
#2
|
|||
|
|||
VB Coding Assistance
See whether this works any better:
Private Sub Command56_Click() Me.Undo DoCmd.Close End Sub You might need Me.Undo twice. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Bunky" wrote in message news I am a novice coder trying to learn VB OJT and I am getting no where. I have a form that the client enters data to go onto the table. I always want the client to enter certain pieces of data then I validate it through VB code. My problem right now is that I have made the form dirty and then have a procedure that occurs beforeupdate event. If the client clicks on the Cancel and Exit button without saving, I get a message that the client must enter the user. On clicking on 'OK' it exits as it should but I cannot get it to quit that display of the msgbox. The click on the Cancel runs this code. Private Sub Command56_Click() DoCmd.CancelEvent DoCmd.Close End Sub and the Before update runs this code. Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Err_BUForm_Click If IsNull(Me.User) Then MsgBox "Please Enter a Specialistbu." Me.User.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.AttendDate) Then MsgBox "Please Enter a valid Datebu." Me.AttendDate.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.Comments) Then MsgBox "Please Enter Commentsbu." Me.Comments.SetFocus Cancel = True GoTo Exit_BUForm_Click End If Exit_BUForm_Click: Exit Sub Err_BUForm_Click: MsgBox Err.Description Resume Exit_BUForm_Click End Sub Any suggestions will be appreciated greatly! |
#3
|
|||
|
|||
VB Coding Assistance
Amazing! Simply Amazing! Thank you, Tremendously!
"Douglas J. Steele" wrote: See whether this works any better: Private Sub Command56_Click() Me.Undo DoCmd.Close End Sub You might need Me.Undo twice. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Bunky" wrote in message news I am a novice coder trying to learn VB OJT and I am getting no where. I have a form that the client enters data to go onto the table. I always want the client to enter certain pieces of data then I validate it through VB code. My problem right now is that I have made the form dirty and then have a procedure that occurs beforeupdate event. If the client clicks on the Cancel and Exit button without saving, I get a message that the client must enter the user. On clicking on 'OK' it exits as it should but I cannot get it to quit that display of the msgbox. The click on the Cancel runs this code. Private Sub Command56_Click() DoCmd.CancelEvent DoCmd.Close End Sub and the Before update runs this code. Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Err_BUForm_Click If IsNull(Me.User) Then MsgBox "Please Enter a Specialistbu." Me.User.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.AttendDate) Then MsgBox "Please Enter a valid Datebu." Me.AttendDate.SetFocus Cancel = True GoTo Exit_BUForm_Click End If If IsNull(Me.Comments) Then MsgBox "Please Enter Commentsbu." Me.Comments.SetFocus Cancel = True GoTo Exit_BUForm_Click End If Exit_BUForm_Click: Exit Sub Err_BUForm_Click: MsgBox Err.Description Resume Exit_BUForm_Click End Sub Any suggestions will be appreciated greatly! |
Thread Tools | |
Display Modes | |
|
|