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

hiding field in form if null and give msgbox if not null

Good day,
I have a form (CSearch) to input data and search for records in a query and displays it on a subform (CAff) once a search button is clicked.

I have a current event on the subform that check if the field "CONTRACTSTATUS" is "Expired" and if so gives a message box saying "This contract is expired"

This works when the main form has been loaded already, but whenever I re-open the form I get error 2424 "The expression you entered..."

Can you help me? Here is the code I'm using:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord Then
  3. Me!CONTRACTSTATUS.Visible = True
  4. End If
  5. If Me.CONTRACTSTATUS.Value = "EXPIRED" Then
  6. MsgBox ("This contract is expired")
  7. Else
  8. Me!CONTRACTSTATUS.Visible = False
  9. Exit Sub
  10. End If
  11. End Sub
Nov 1 '13 #1

✓ answered by NeoPa

Thank you.

I expect that means that the subform is using a recordset that is non-updatable. In such a case, when the main form has not yet been used to specify the search, there are no records in the subform at all. As it's not updatable there is not even any possibility of it being at the New Record position. From here Me.CONTRACTSTATUS.Value has no meaning as there is no current record from which it can take context.

In short, your code needs first to check if there is a current record before it tries to refer to it.

I hope that helps, and I'm a little confused that, in such a scenario, it would even trigger the Current event. Check out that idea anyway and see what you find.

3 1403
NeoPa
32,556 Expert Mod 16PB
Please could you include the full error message and the number of the line of code wher it occurs.
Nov 1 '13 #2
Run-time error '2424':

"The expression you entered has a field, control, or property name that toolbox can't find"

And when I click on Debug, line # 5 is highlighted.
Nov 1 '13 #3
NeoPa
32,556 Expert Mod 16PB
Thank you.

I expect that means that the subform is using a recordset that is non-updatable. In such a case, when the main form has not yet been used to specify the search, there are no records in the subform at all. As it's not updatable there is not even any possibility of it being at the New Record position. From here Me.CONTRACTSTATUS.Value has no meaning as there is no current record from which it can take context.

In short, your code needs first to check if there is a current record before it tries to refer to it.

I hope that helps, and I'm a little confused that, in such a scenario, it would even trigger the Current event. Check out that idea anyway and see what you find.
Nov 1 '13 #4

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

Similar topics

1
by: cbielins | last post by:
I would like to alter a table's column from null to not null. Is this possible or can you only do the reverse? If I can do it, what's the syntax, the .pdf doesn't describe it. TIA, Chris
1
by: Jacky11 | last post by:
Can anyone help me? Please see the code I'm using now. Public Function sheetlayout() On Error GoTo Err_Command1_Click Dim xl As Object Set xl = GetObject("c:\windows\desktop\123.csv")...
6
by: Miguelito Bain | last post by:
hi everybody- i have a form with 2 fields on it that i want the user to fill out before he or she can save the record, close the record, or move to the next record, etc... here's the code i...
1
by: Lance | last post by:
Is there a "best" technique for hiding a form's Close ControlBox button (i.e., the button with an "X" in the top-right corner of a form) but still show the minimize and maximize buttons? I've found...
3
by: Tony | last post by:
Hi, I wonder why when I do a filter by form, some text fields show all the data in the table in the combo box and others only show two items, Is Null and Not Is Null. I want to show all data,...
13
by: Jiho Han | last post by:
Here's the issue. You have a class, Class Person { public int id; public string firstname; public string lastname; }
11
by: Alex | last post by:
Hello all, I have a main form(say "form1") .i want to display another form(say "form2") on occuring of an event (say a button click) and want to hide it after some time so that it will again...
2
by: mars123 | last post by:
hi, I am facing a js error in my code, below is the prob. statement I have a radio2 javascript function as below, it works like this.. When a parent radio button is selected only one of its...
8
by: Lucrecious | last post by:
How do I create a dynamic report based on a query that updates from a select field form? I followed the information from the article here entitled: "Checkbox form to allow user to select query output...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.