Solved Nz(string,ifnull(my string)) (1 Viewer)

Reshmi mohankumar

Registered User.
Local time
Today, 18:09
Joined
Dec 5, 2017
Messages
101
Me.simg.Picture = Nz(CurrentProject.Path & StudentPhoto, CurrentProject.Path & "\StudentImages\INDEX.JPG")
Me.fimg.Picture = Nz(CurrentProject.Path & FatherPhoto, CurrentProject.Path & "\StudentImages\INDEX.JPG")

But this code is under forms onCurrent event
if there is a no string i got error like '2220' can't open the file "F:\SmartSchool".
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:39
Joined
Oct 29, 2018
Messages
21,454
Hi. Where did "F:\SmartSchool" come from?
 

Isaac

Lifelong Learner
Local time
Today, 05:39
Joined
Mar 14, 2017
Messages
8,774
You might need to use something along the lines of Dir() or a Filesystemobject rather than NZ. NZ is to test database record columns for Null.
 

Reshmi mohankumar

Registered User.
Local time
Today, 18:09
Joined
Dec 5, 2017
Messages
101
Hi. Where did "F:\SmartSchool" come from?
i hope i used currentproject.path used in value if null place so.
my db had only path string if which are having paths they can visible , but which are not having path i got error like above.
 

plog

Banishment Pending
Local time
Today, 07:39
Joined
May 11, 2011
Messages
11,638
NZ has 2 arguments:

1. The thing you are testing (CurrentProject.Path & StudentPhoto)
2. What to use when that first thing is NULL ( CurrentProject.Path & "\StudentImages\INDEX.JPG")

For #1 to be truly NULL both parts must be NULL. If CurrentProject.Path has a value but StudentPhot doesn't, it evaluates to true and the second part isn't used. Most likely Part 1 should only test StudentPhoto and CurrentProject.Path should not be anywhere in the NZ:

=CurrentProject.Path & NZ(StudentPhoto, "\StudentImages\INDEX.JPG" )
 

Reshmi mohankumar

Registered User.
Local time
Today, 18:09
Joined
Dec 5, 2017
Messages
101
You might need to use something along the lines of Dir() or a Filesystemobject rather than NZ. NZ is to test database record columns for Null.
I dont know how to use them....Is simple inline code??
 

Reshmi mohankumar

Registered User.
Local time
Today, 18:09
Joined
Dec 5, 2017
Messages
101
NZ has 2 arguments:

1. The thing you are testing (CurrentProject.Path & StudentPhoto)
2. What to use when that first thing is NULL ( CurrentProject.Path & "\StudentImages\INDEX.JPG")

For #1 to be truly NULL both parts must be NULL. If CurrentProject.Path has a value but StudentPhot doesn't, it evaluates to true and the second part isn't used. Most likely Part 1 should only test StudentPhoto and CurrentProject.Path should not be anywhere in the NZ:

=CurrentProject.Path & NZ(StudentPhoto, "\StudentImages\INDEX.JPG" )

it worked...And i learnt good point
i need to have strong skills ....You took me cafe to refresh...Thank you sir
 

Isaac

Lifelong Learner
Local time
Today, 05:39
Joined
Mar 14, 2017
Messages
8,774
I dont know how to use them....Is simple inline code??
Well, your original post didn't actually explain what your goal is. I had to interpret it from looking at your code, which makes it look like you are testing for the existence of files by using NZ--which won't work.
If plog is right, and you're actually just wanting to run a logic like this:
If a certain Form control's value is Null, then display CurrentProject.Path & "\StudentImages\INDEX.JPG
...Then I would recommend his suggestion.

If, in contrast, you actually want to check for the existence of a windows file (does it exist or not?), then you want to look into using Dir() or FSO
 

Reshmi mohankumar

Registered User.
Local time
Today, 18:09
Joined
Dec 5, 2017
Messages
101
Well, your original post didn't actually explain what your goal is. I had to interpret it from looking at your code, which makes it look like you are testing for the existence of files by using NZ--which won't work.
If plog is right, and you're actually just wanting to run a logic like this:
If a certain Form control's value is Null, then display CurrentProject.Path & "\StudentImages\INDEX.JPG
...Then I would recommend his suggestion.

If, in contrast, you actually want to check for the existence of a windows file (does it exist or not?), then you want to look into using Dir() or FSO
finally im good. thank you bro
 

Users who are viewing this thread

Top Bottom