473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Close Button/required Field

Using Access '97

Hi there, am wondering if there is a way to have a CLOSE button on the form and have it NOT CLOSE the form unless all the REQUIRED controls have an entry.

I have 3 items I would LOVE to find out about:
1 / I have created a button that I have attached to following code to and it seems to check the fields and it gives me a WARNING that a particular field needs to have an entry if something is missing. This is good, and it works.
2 / After it checks, I need to know if there is a way to attach the CLOSE button code to this and have it NOT CLOSE if there is something missing abd CLOSE if all fields have an entry.
3 / If all controls have an entry in them, I need to capture a date and time. If all the fields don't have an entry, I don't want the form to close and also no date.
4 / I also need to capture a 2nd date when all the NOT REQUIRED fields have been entered at a later date.

Is this possible?

Thank you in ADVANCE FOR YOUR ASSISTANCE.
Kind regards



Private Sub Command325_Click()


Dim FLAG As Integer

If Not IsNull(Me.F_ERGONOMICS!ERGO_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_HUMAN_FACTOR!HUMAN_FAC_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_PERSONAL!PROT_EQUIP_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_POLICY!POLICY_PROC_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_MGMT_SYSTEMS!MGMT_SYS_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_TOOLS!TOOLS_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_WORKPLACE!WORKPLACE_CODE) Then
FLAG = 1
End If

If FLAG >= 1 Then
FLAG = 0
Else
MsgBox "You need to make an entry in at least one of the KEY FACTORS"
End If



If Nz(Me.SRI) = "" Then
MsgBox ("Missing SRI on the 1st tab.")
End If
If Nz(Me.LOC_CODE) = "" Then
MsgBox ("Missing LOCATION CODE on 1st tab.")
End If
If Nz(Me.COST_CTR) = "" Then
MsgBox ("Missing COST CENTER on 1st tab.")
End If
If Nz(Me.INCIDENT_DATE) = "" Then
MsgBox ("Missing DATE OF INCIDENT on 1st tab.")
End If
If Nz(Me.INCIDENT_TIME) = "" Then
MsgBox "Missing TIME OF INCIDENT on 1st tab"
End If
If Nz(Me.WEEKDAY_CODE) = "" Then
MsgBox ("Missing WEEKDAY INCIDENT OCCURRED on 1st tab.")
End If


End Sub
Jul 10 '07 #1
1 1848
hyperpau
184 Expert 100+
Using Access '97

Hi there, am wondering if there is a way to have a CLOSE button on the form and have it NOT CLOSE the form unless all the REQUIRED controls have an entry.

I have 3 items I would LOVE to find out about:
1 / I have created a button that I have attached to following code to and it seems to check the fields and it gives me a WARNING that a particular field needs to have an entry if something is missing. This is good, and it works.
2 / After it checks, I need to know if there is a way to attach the CLOSE button code to this and have it NOT CLOSE if there is something missing abd CLOSE if all fields have an entry.
3 / If all controls have an entry in them, I need to capture a date and time. If all the fields don't have an entry, I don't want the form to close and also no date.
4 / I also need to capture a 2nd date when all the NOT REQUIRED fields have been entered at a later date.

Is this possible?

Thank you in ADVANCE FOR YOUR ASSISTANCE.
Kind regards



Private Sub Command325_Click()


Dim FLAG As Integer

If Not IsNull(Me.F_ERGONOMICS!ERGO_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_HUMAN_FACTOR!HUMAN_FAC_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_PERSONAL!PROT_EQUIP_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_POLICY!POLICY_PROC_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_MGMT_SYSTEMS!MGMT_SYS_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_TOOLS!TOOLS_CODE) Then
FLAG = 1
End If

If Not IsNull(Me.F_WORKPLACE!WORKPLACE_CODE) Then
FLAG = 1
End If

If FLAG >= 1 Then
FLAG = 0
Else
MsgBox "You need to make an entry in at least one of the KEY FACTORS"
End If



If Nz(Me.SRI) = "" Then
MsgBox ("Missing SRI on the 1st tab.")
End If
If Nz(Me.LOC_CODE) = "" Then
MsgBox ("Missing LOCATION CODE on 1st tab.")
End If
If Nz(Me.COST_CTR) = "" Then
MsgBox ("Missing COST CENTER on 1st tab.")
End If
If Nz(Me.INCIDENT_DATE) = "" Then
MsgBox ("Missing DATE OF INCIDENT on 1st tab.")
End If
If Nz(Me.INCIDENT_TIME) = "" Then
MsgBox "Missing TIME OF INCIDENT on 1st tab"
End If
If Nz(Me.WEEKDAY_CODE) = "" Then
MsgBox ("Missing WEEKDAY INCIDENT OCCURRED on 1st tab.")
End If


End Sub
This sounds simple. I just don't understand your FLAGS and why I see Nz in your codes.

Let's say, you have 4 required controls.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command325_Click()
  2.  
  3. If IsNull(Me.Control1) Then
  4.     MsgBox "Control 1 is required"
  5.  
  6. ElseIf   IsNull(Me.Control2) Then
  7.     MsgBox "Control 2 is required"
  8.  
  9. ElseIf   IsNull(Me.Control3) Then
  10.     MsgBox "Control 3 is required"
  11.  
  12. ElseIf  Isnull(Me.Control4)  Then 
  13.     MsgBox "Control 4 is required"
  14.  
  15. Else
  16.       Me![Name of your Date and Time Control] = Now( )
  17.       DoCmd.Close
  18.  
  19. End If
  20.  
  21. End Sub

The Only problem I see in your code is that you separated all your
It..Then statements in to several If...Then Statements instead of putting
Then together in just one If...Then...ElseIf...Then...Else Statement.
Jul 12 '07 #2

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

Similar topics

6
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
6
by: Kenny G | last post by:
Reference the below sub: I can't get the message box to close and therefore the user can't enter anything - Y or N in the OralAntibiotics box. Your help is appreciated. Private Sub...
1
by: Ebrahim | last post by:
This message is in reply to a prev 1 . My application refues to close . Some one had suggested that I might have threads running.. but i solved that problem too . The app still refuses to close...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
2
by: Bert Szoghy | last post by:
Hello, I am missing something about Visual Basic .NET module variables and window close events. In the following code, after opening Form2 by clicking a button on Form1 and then closing...
1
by: Stephen D Cook | last post by:
What I am trying to do is have a set of option buttons which are required to click one. If the person doesn't click any before insert, they get an error. If they do click one, it inserts into the...
1
by: Stephen D Cook | last post by:
In my form I have an option group with 3 option buttons. My form is tied to a table. the options are Temp, Permanent and Overtime. I have these inside a frame. I have an AddRecord button to enter...
7
by: tarun.kataria | last post by:
Hi All, Is there any way to detect that the user is trying to Xout the browser window instead of hitting a button. Because in my application I want to make it sure that they dont do it either...
2
by: Del | last post by:
I have a popup form that consist of a single field called EnteredBy and a Subform that has three fields. The popup form also has a button in the Form Footer called close. In the On Click event I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.