Field Visible if Value Is Not Null

PennyPitSt0p

Access 2000 Amateur
Local time
Today, 00:47
Joined
Mar 2, 2006
Messages
16
OK, I have a field (info_updated) on my form (precall_form_view) that I only want to be visible on the form when the value in that field is not null.

I have looked through the forums, and I can not seem to find an example that is like what I am looking for. It may be in there, but sometimes what I call things are not what they are really called.... :D

Here is my code, but when I use it, I never see the field.

I am sure that it is a logic error, and I am too close to see it, but can someone look and advise? :confused:

Thanks!

Private Sub Form_Current()
If Info_Updated = Not Null Then
Info_Updated.Visible = True
Else
Info_Updated.Visible = False
End If

End Sub
 
Code:
If IsNull(Info_Updated) Or Info_Updated = "" Then
     Info_Updated.Visible = False
Else
     Info_Updated.Visible = True
End If
That should go in the forms OnCurrent event.
 
Works like a charm!

It does not look a whole lot different than what I had. Why did yours work and mine didn't? Was it the format? You had the null first...

Thanks!
 
Look closer for there is a big difference between your code and mine [which works].

You can not test for Nulls with = Null or <> Null. You have to use the IsNull() function. I am also testing for empty strings.
 
OK. That makes sense to me now.

Thank you for your input. I have only been doing this for less than two weeks, and I have no formal training, so explanations really help.

The empty string thing is great! I would not have thought to test for that, even though I know that I have seen empty strings come through on importing data into a table.

Thanks again!
 
New Variation

Is there a way that I can show a field, briefly, if a user navigates to another record.

I want to warn the users, but not use a VBOKOnly, VBYESNO or anything that they would need to actually respond to.

I created a field in precall_form_view called Internal_message.

I was thinking that a timer event could work for this, but I can not seem to make it work.

If someone could help, I would appreciate it.

Thanks!
 
What are you trying to prevent or warn the user about?

The forms Before Update event is the key to data validation at the form level.

Check these links out for some working examples that will assist your project.

A Better Mouse Trap?

Enable/Disable The Control Box X Button

Searching the forum is a great way to discover and learn the answers to your Access programming questions.
 
Simple

Simply that they are navigating to the next record.

I had some really slick code created that popped up a message box that told the user that they were changing records, but my manager found it annoying that it beeped and made the user acknowledge it.

The internal message field simply shows the phrase "record navigation" and is bordered in yellow.

I did the following on open and on current, and I only see that field on the first record and not when I navigate to the next record.

We are trying to make sure that the user who is doing other job functions based off of the record shown on other systems is warned when they change records so they do not cross data from a different record.

Does this make sense? I really like your mousetrap, but that is me, my boss is the one creating this nightmare for me!!!! hehehehe...

Private Sub Form_Current()
Me.TimerInterval = 1000

End Sub
Private Sub Form_Timer()
Me.Internal_Message.Visible = False
Me.TimerInterval = 0
End Sub
 
In that case then you should insist to your boss that the users are warned if they try to leave a dirty record that they either undo their changes or save their changes. Otherwise Access will save the changes and they user might not have realized that they made a change to the record and now a bogus change has been saved. The only time my mouse trap code routine will alert the user is if the record is dirty [has been modified but not saved]. Data integrity should be a high priority over a user having to click a message prompt.
 

Users who are viewing this thread

Back
Top Bottom