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

Please help with image linkage.

Status
Not open for further replies.

InfoNow

IS-IT--Management
Apr 20, 2001
106
US
the code below works fine if the LotNum only contain numbers. I have lotnum that also contain letters. How do I change the code below so that it allows numbers and letters.

___________________________________________________
Private Sub Form_Current()
If Me![LotNum] <> 0 Then
Me!Image160.Picture = &quot;c:\LotNumbers\&quot; & Me![LotNum] & &quot;.gif&quot;
Label162.Caption = &quot;File: &quot; & &quot; c:\LotNumbers\&quot; & Me![LotNum] & &quot;.gif&quot;

Else
Exit Sub
End If
 
hmm ... wonder if this line would work?

Try this:

If Not(Me![LotNum] = 0) Or Not(IsNull(Me![LotNum]) Or Not (Me![LotNum] = &quot;&quot;) Then

Instead of:

If Me![LotNum] <> 0 Then

I think as long as all the cases in the first statement test correctly, this should work ... try it, and if you get any error messages, post them on here. :)

HTH

Greg
 
In access - how do I link a picture in a form so it will change when I change the form no. Example No. l form will have information about a bread of a kitten - which I will have a picture of - the next form will have information on a puppy and the picture will be of a puppy
 
Greg,
Thank you for your reply. The Whole line didn't work. The error message was &quot;run-time error '13': Type mismatch&quot;
but if I only use:
If Not (Me![LotNum] = &quot;&quot;) Then
it works fine. Will I run into trouble if I just use that?

TIA
 
Out of curiosity, how is the LotNum defined in your table?
 
Greg,
The LotNum is defined as a text field with a length of 12 characters and is indexed with no duplication allowed.
 
InfoNow,

Maybe do this instead:

***********************************
Private Sub Form_Current()
Dim LotNumber as String
Lotnumber = Me![LotNum]
If Lotnumber <> 0 Then
Me!Image160.Picture = &quot;c:\LotNumbers\&quot; & Me![LotNum] & &quot;.gif&quot;
Label162.Caption = &quot;File: &quot; & &quot; c:\LotNumbers\&quot; & Me![LotNum] & &quot;.gif&quot;

Else
Exit Sub
End If
**********************************

Just an idea.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
OK ... that's what I was looking for ... I should have asked that in the first place! :p

Use the following line ...

If Not(IsNull(Me![LotNum]) Or Not (Me![LotNum] = &quot;&quot;) Then

Using the above will allow your LotNum field to contain letters, numbers, etc.

The reason for the type mismatch error is as follows:

&quot;Verify that the criteria you specified is for the same data type as the data in the underlying table or query. For example, the field ReorderLevel has a Number data type. Therefore, if you type the criteria &quot;50&quot;, you'll get an error because Microsoft Access interprets values in quotation marks as text, not numbers.&quot;

- Microsoft Access97 Help Files

Yah, yah, I know - but I can't convince my company to upgrade! LOL

HTH

Greg
 
bspiffie,
You can accomplish this by adding an OLE object field to the table that you store your information in - this will save the linked or embedded image in the table with it's respective record. Have the when you add the OLE object field to your form, just add those images to the object box - one for each record (or more if you set it up for more)
-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Greg,
That works just the way I wanted. Thank you very much for your help.


Josh,
The reason I am doing it this way is because my DB was growing out of control. The reason it is growing so much is due to embedded images (over 1300). Someone on this forum (thank you again) suggested I link the images using image instead of OLE objects. It worked great now. My DB was 965mb and now it is only 32mb. Awesome!!!!

Thank you for everyone's help...

 
InfoNow,
If you look closely, I was replying to the post that someone snuck into your forum.. ;-) I figured you wouldn't want to embed a few thousand images into a database that has a size limit. I always recommend linking over embedding. I hope I helped the 'bspiffie' user that posted his question.

I'm glad you got your questoin answered. Goodluck.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
No need for apologies! ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top