473,387 Members | 1,592 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,387 software developers and data experts.

CLOSE Button

Access '97

Hi there. I have the following code:

If Nz(Me.Author_Name) = " " then
Btn_Close.enabled = FALSE
MsgBox "Missing Author Name"
else
Btn_Close.enabled = TRUE
End If

When I test my form out, this code disables the CLOSE button when the control is blank. For some reason, after the control has an entry, the CLOSE button still does not become enabled until after I exit out of the entire record. Is there a way to have it become enabled immediately after the entry in the control?

Thank you
Jul 11 '07 #1
6 1534
missinglinq
3,532 Expert 2GB
Where do you have this code placed?
Jul 11 '07 #2
Where do you have this code placed?
Hi there, I have this code at the FORM level and on the OnCurrent event.
It seems that when I use the navigation arrows and move from one record to another, then it recognizes the change, but just by making an entry into the control, it does not affect the CLOSE button.

Thank you for assisting me.
Jul 11 '07 #3
missinglinq
3,532 Expert 2GB
That's what the OnCurrent event does, it fires anytime you move from one record to another! Since you don't want the user to be able to Close the ofrm until the Author_Name has a value in it, do two things.

Set the form so that on going from one record to another the Focus is set on Author_Name. Do that by adding this line to the code you already have in Form_Current:
Expand|Select|Wrap|Line Numbers
  1. Me.Author_Name.SetFocus
Then use basically the same code you already tried in the Author_Name_Exit sub, with one additional line, Line 5:

Cancel = True

This line automatically returns Focus to the field. Something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Author_Name_Exit(Cancel As Integer)
  2.  If Nz(Me.Author_Name) = "" Then
  3.    btn_close.Enabled = False
  4.    MsgBox "Missing Author Name"
  5.    Cancel = True
  6.  Else
  7.    btn_close.Enabled = True
  8. End If
  9. End Sub
  10.  
Good Luck!

Linq ;0)>
Jul 11 '07 #4
That's what the OnCurrent event does, it fires anytime you move from one record to another! Since you don't want the user to be able to Close the ofrm until the Author_Name has a value in it, do two things.

Set the form so that on going from one record to another the Focus is set on Author_Name. Do that by adding this line to the code you already have in Form_Current:
Expand|Select|Wrap|Line Numbers
  1. Me.Author_Name.SetFocus
Then use basically the same code you already tried in the Author_Name_Exit sub, with one additional line, Line 5:

Cancel = True

This line automatically returns Focus to the field. Something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Author_Name_Exit(Cancel As Integer)
  2.  If Nz(Me.Author_Name) = "" Then
  3.    btn_close.Enabled = False
  4.    MsgBox "Missing Author Name"
  5.    Cancel = True
  6.  Else
  7.    btn_close.Enabled = True
  8. End If
  9. End Sub
  10.  
Good Luck!

Linq ;0)>
But what if I have 2 required controls on a form? Would I set the SetFocus for each of the required controls in each batch of code? In other words, if I write the code for the AUTHOR NAME and then write the same code for the AUTHOR TITLE. Would I have a SetFocus for each control?

Thank you.
Jul 11 '07 #5
That's what the OnCurrent event does, it fires anytime you move from one record to another! Since you don't want the user to be able to Close the ofrm until the Author_Name has a value in it, do two things.

Set the form so that on going from one record to another the Focus is set on Author_Name. Do that by adding this line to the code you already have in Form_Current:
Expand|Select|Wrap|Line Numbers
  1. Me.Author_Name.SetFocus
Then use basically the same code you already tried in the Author_Name_Exit sub, with one additional line, Line 5:

Cancel = True

This line automatically returns Focus to the field. Something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Author_Name_Exit(Cancel As Integer)
  2.  If Nz(Me.Author_Name) = "" Then
  3.    btn_close.Enabled = False
  4.    MsgBox "Missing Author Name"
  5.    Cancel = True
  6.  Else
  7.    btn_close.Enabled = True
  8. End If
  9. End Sub
  10.  
Good Luck!

Linq ;0)>
That is WONDERFUL!! Thank you VERY MUCH!! :)
Jul 11 '07 #6
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Jul 11 '07 #7

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: Sujan | last post by:
Hello all, Help me! -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="JavaScript"> <!--
1
by: dibyendu_k | last post by:
Hi, There is a problem i cant solve regarding Internet Explorer 5.5. It is regarding the Print Dialog Box. From a webpage if I open a popup window (window.open()) containing buttons Print and...
5
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
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...
2
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. ...
0
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
7
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.