473,473 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

null problem

Kaosu
19 New Member
I am trying to get the database to display the picture of the person on the current record and if not to display the company logo.

At the moment I cant get the form to recognise the value as Null and not try and display a picture that does not exist bringing up a 2220 runtime error.



Private Sub Form_Current()

imgTxt.Value = "W:\training database\Pictures\" & SQSID & ".jpg"

If imgTxt.Value = Null Then
Pic.Picture = "W:\training database\Pictures\sqs.bmp"
Else
Pic.Picture = imgTxt.Value
End If

End Sub
Oct 10 '07 #1
5 1535
Jim Doherty
897 Recognized Expert Contributor
I am trying to get the database to display the picture of the person on the current record and if not to display the company logo.

At the moment I cant get the form to recognise the value as Null and not try and display a picture that does not exist bringing up a 2220 runtime error.



Private Sub Form_Current()

imgTxt.Value = "W:\training database\Pictures\" & SQSID & ".jpg"

If imgTxt.Value = Null Then
Pic.Picture = "W:\training database\Pictures\sqs.bmp"
Else
Pic.Picture = imgTxt.Value
End If

End Sub

Change
Expand|Select|Wrap|Line Numbers
  1.  If imgTxt.Value = Null 
to
Expand|Select|Wrap|Line Numbers
  1.  If IsNull(Me!img) Then
Oct 10 '07 #2
Kaosu
19 New Member
the imgTxt is actualy a txtbox with the path for the img.
i changed the code to

If IsNull(Me!imgTxt) Then

but its still skipping the null, bring up the runtime error and stating that...

imgTxt = "W:\training database\Pictures\" & SQSID & ".jpg"
......

Pic.Picture = imgTxt.Value


is missing
Oct 10 '07 #3
Jim Doherty
897 Recognized Expert Contributor
the imgTxt is actualy a txtbox with the path for the img.
i changed the code to

If IsNull(Me!imgTxt) Then

but its still skipping the null, bring up the runtime error and stating that...

imgTxt = "W:\training database\Pictures\" & SQSID & ".jpg"
......

Pic.Picture = imgTxt.Value

is missing
If its skipping over the true part of the IF expression then it means it isnt null

leave the word VALUE out just refer to the control Me!imgtxt

You might want to consider also doubling up on the first if statement to take account of any zero length string

If IsNull(Me!imgTxt) Or Me!imgTxt ="" THEN

Wheres is the value SQSID coming from?and also when using a textbox or any other control on a form get into the habit of including a reference to the form on which the textbox is mounted using the ME keyword

Regards

Jim
Oct 10 '07 #4
Kaosu
19 New Member
Wheres is the value SQSID coming from?and also when using a textbox or any other control on a form get into the habit of including a reference to the form on which the textbox is mounted using the ME keyword
"W:\training database\Pictures\" & SQSID & ".jpg"

"SQSID" is the name of the key field.
each persons picture is numbered with their company id so that when the picture is put into the folder it will automatically show up when scrolling through the records (if i ever get it to work).

just tested it and its still not working with

If IsNull(Me!imgTxt) Or Me!imgTxt ="" THEN

its still trying to find the path of a file that doesn't exist.
is null even the right statement to be using?

i highlighted the Me!imgTxt and saw

Me!imgTxt = "W:\training database\Pictures\3.jpg"
(i only have 2 jpg's in the folder atm so 3 does not exist)


and i think the problem is that even though the file does not exist the path is still stored in the txtbox.
is there another way of checking if that file exists or not?
Oct 10 '07 #5
Kaosu
19 New Member
after another hard days work browsing google i got it to work.

Private Sub Form_Current()

If Dir("W:\training database\Pictures\" & SQSID & ".jpg", vbNormal) <> "" Then
Me!imgTxt = "W:\training database\Pictures\" & SQSID & ".jpg"
Else
Me!imgTxt = ""
End If

If IsNull(Me!imgTxt) Or Me!imgTxt = "" Then
Pic.Picture = "W:\training database\Pictures\sqs.bmp"
Else
Pic.Picture = imgTxt

End If

End Sub


thx for ur input jim
Oct 10 '07 #6

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

Similar topics

1
by: Sascha | last post by:
Hi I need some help on achieving the following: I wrote a querie which collects Data out of three Tables, the Result looks like this: SET NOCOUNT ON DECLARE @ROW INT
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
27
by: David W | last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like this: void f( int& p ) { printf( "%d\n", p ); } int main (int argc, char *argv) {
3
by: Jon L | last post by:
Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the language. I'm using the Microsoft.XMLDOM object...
8
by: A. Anderson | last post by:
Howdy everyone, I'm experiencing a problem with a program that I'm developing. Take a look at this stack report from GDB - #0 0xb7d782a3 in strlen () from /lib/tls/i686/cmov/libc.so.6 #1 ...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.