Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop an action in Access with VBA

Status
Not open for further replies.

MarkWright

Programmer
Jan 7, 2003
66
DE
Hello, I am trying to stop a "by closing" action. I have some Fields that have to be filled out before the formular can be closed. I have been using ( if isnull(field) ) but am not having anyluck stopping the close procedure.
What I would like to do is if a Field is empty but should have something in it that when the Formular is to be closed that a MSGbox comes up and says that Field X has no information and has to be filled out. I want to action to stop and after clicking ok on the Msgbox to return to the Formular to fill out the Fields that need to be filled out.
I have been trying with this code ->
If IsNull(Information.Value) Then

' With Form
' .AbbrechenEreignis
' .AllowAdditions = True
' Information = InputBox("Information", "frmPBS_Testzyclus", "xxxxx")
' End With
' Me.Information.SetFocus
' Exit Sub
End If
but have been having no luck. One Problem is that I have txt and cbo Fields that need to be filled out.
Thanks for your time
Mark
 
How about something like this :-
'----------------------------------------------
Sub data_entry()
'- user cannot escape until 2 values entered
While Me.textbox1.Value = "" And Me.textbox2.Value = ""
Me.Show
If Me.textbox1.Value = "" And Me.textbox2.Value = "" Then
MsgBox ("Must enter 2 values.")
End If
Wend
Me.Hide
End Sub
'------------------------------------------------
Regards
BrianB
** Let us know if you get something that works !
================================
 
Hello, and thanks. I have another code that I made to check my field.
The Msgbox is in German beacuse that is where I am Working but othere than that this works fine. when one or more Fields are not filled the user becomes a msgbox, the close function is cancled and the user can add the information to the given field. Thanks againe for your time and Help
Mark
Oh if your interested I have another code where I Hide a second formular where 2 formulars are together. (In German its an Under formular but am not sure if that is the name in English.) Just let me know and I'll send it to you, if you wish.
code->
'*** close frmTestzyclus
'*** field check for needed Information. Certain fields must have information give
Private Sub closeTestzyclus_Click()

On Error GoTo Err_closeTestzyclus_Click

If IsNull(Produkt.Value) Then
MsgBox "Produktfeld Bitte ausfüllen "
Exit Sub
ElseIf IsNull(System.Value) Then
MsgBox "Systemfeld Bitte ausfüllen "
Exit Sub
ElseIf IsNull(Status.Value) Then
MsgBox " Statusfeld Bitte ausfüllen "
Exit Sub
ElseIf IsNull(Tester.Value) Then
MsgBox " Testerfeld Bitte ausfüllen "
Exit Sub
ElseIf IsNull(Entwickler.Value) Then
MsgBox " Entwicklerfeld Bitte ausfüllen "
Exit Sub
ElseIf IsNull(Information.Value) Then
MsgBox " Informationfeld Bitte ausfüllen "
Exit Sub

End If

DoCmd.Save
DoCmd.Close

Exit_closeTestzyclus_Click:

Exit Sub

Err_closeTestzyclus_Click:
MsgBox Err.Description
Resume Exit_closeTestzyclus_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top