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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 2427 - turning text boxes off on another field 1

Status
Not open for further replies.

blade6247

Programmer
Jan 20, 2005
13
GB
I have a report that keeps on crashing with 2427 error.

I need a text box (Statutory Books) to be invisible if another field (satstat) = "Yes" (its a lookup text field in the table) or visible if it reads "no" or "partly"

The field definately has Yes / No in it, but for some reason access regards it as empty.

The code I use is

IF [satstat] = "Yes" THEN
[Statutory Books].Visible = False
ELSE
[Statutory Books].Visible = True
END IF
 
Hi,

I don't think that 'satstat' DOES contain a non-null value.
To check this at run-time do the following:

Right-click the 'IF [satstat]...' line and choose 'Toggle -> Breakpoint' on.

Run the form, and when it stops and displays this line of code, then hover your mouse over the word '[satstat]'. It will more than likely tell you that the field is null.
If not, keep pressing F8 (continue code) until it comes to the specific record that causes the 2427 error.

If this error occurs for the first record (thus assuming that all records would produce this error), then either the field is not being pulled into the form via the form datasource, or your data is not in fact "Yes", but "YES" or " Yes" or "Yes " etc.

If the form datasource is a tablename, then it will be pulling this field in, if it's a query, then check that the query refers to this field.

If no joy there, then replace your code with this:
[tt]
IF trim(ucase([satstat])) = "YES" THEN
[Statutory Books].Visible = False
ELSE
[Statutory Books].Visible = True
END IF
[/tt]

This will strip spaces and ensure an uppercase check.

Another check:
Change an 's' in 'satstat' in this line of code to uppercase. Move the cursor down from this line. If the editor changes the 'S' back to 's', then the fieldname is correct, otherwise the fieldname is wrong. (Is the form datasource actually pulling this value into the form?).

Hope this helps,

Darrylle
















either the you will probably find that this



Never argue with an idiot, he'll bring you down to his level - then beat you with experience. darrylles@yahoo.co.uk
 
Aaargh! I had this working before lunch and now its just stopped!

The value is null it appears when I use the "watch function"

The code is in the report "on activate" event - it seems to work wen I switch in the report from design to normal view, but not when I activate the report from the database window.

Satstat isn't a query criteria thats needs to be entered by the user but just another field in the main record table. Is this causing the problem?
 
I expect the issue is
The code is in the report "on activate" event
The code should be in the On Format event of the section containing the controls.

satstat must be a control name in your report. To resolve possible Null issues, use
Code:
IF Me.[satstat] & "" = "Yes" THEN
   Me.[Statutory Books].Visible = False
  ELSE
   Me.[Statutory Books].Visible = True
END IF
or
Code:
   Me.[Statutory Books].Visible = _
       (Me.[satstat] & "" <> "Yes")


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top