473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to link Drawings in Access 2003

greeni91
I am currently trying to fix up my old database and I have hit a bit of a snag...

I am trying to link a drawing (bitmap image) to a form.

I have set up a table with the Path to the image in one column and the part number it corresponds to in the other.

On my main form I have a button next to the part number field which I want to use to display the images in another form. It copies the part number from the main form and pastes it to the part number in the "Drawing" form.

I tried to use a DLookup to display the image but to no avail.

I have also tried the Microsoft way of doing things but their explanations of what needs to be changed from the template is rather s**t.
Jun 1 '10 #1
13 2026
ADezii
8,834 Expert 8TB
@greeni91
Just subscribing, will return later. Is Part Number a String or Number?
Jun 1 '10 #2
@ADezii
The Part Number is set as a string as it begins with 2 letters, e.g. AG55470.

/Sandy
Jun 1 '10 #3
ADezii
8,834 Expert 8TB
  1. Open the 2nd Form via the OpenForm() Method, and pass the Part Number via the OpenArgs Property (PartNum should be Required):
    Expand|Select|Wrap|Line Numbers
    1. DoCmd.OpenForm "frmImages", acNormal, , , acFormEdit, acWindowNormal, Me![txtPartNum]
  2. In the Open() Even of the 2nd Form:
    • Copy the Part Number to the Text Box on the 2nd Form.
    • Use the DLookup() Function to retrieve the associated Path for the given Part Number.
    • If the Path is NULL, get outta Dodge!
    • If the Image Path is invalid, get outta Dodge!
    • If all is well, set the Picture Property of the Image Control to the Value retrieved from DLookup().
  3. Replace with your own Control/Form Names.
  4. Any questions, feel free to ask.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. Dim varPictureToLoad
    3.  
    4. Me![txtPartNum] = Me.OpenArgs
    5.  
    6. varPictureToLoad = DLookup("[Path]", "tblImages", "[PartNum] = '" & Me.OpenArgs & "'")
    7.  
    8. If IsNull(varPictureToLoad) Then
    9.   MsgBox "No Picture to Load", vbExclamation, "No Value in Field"
    10.     DoCmd.Close
    11. Else
    12.   If Dir$(varPictureToLoad) <> "" Then
    13.     Me![imgTest].Picture = varPictureToLoad
    14.   Else
    15.     MsgBox varPictureToLoad & " is not a valid Path", vbExclamation, "Invalid Path"
    16.       DoCmd.Close
    17.   End If
    18. End If
    19. End Sub
Jun 1 '10 #4
@ADezii
I have tried your code it is so close to working it is unreal. I am having a small problem when defining the Me.OpenArgs object.

When I run the code it gives me the error:

Run-time error '2448':
You can't assign a value to this object

I have remembered and changed all form names and control names in the code and when in debug mode it highlights

Me![PartNumber] = Me.OpenArgs.

When I scroll over this comment it says each half equals the part number from the 1st form, so I can't see the problem.

Hope you can help
Jun 2 '10 #5
ADezii
8,834 Expert 8TB
@greeni91
  1. Is that a Comma or Period that I see after OpenArgs? If so, remove it.
  2. Did you place this Code in the Open() Event of the 2nd Form, the one containing the Image Control?
Jun 2 '10 #6
Sorry about that... The period was because I had reached the end of my sentence. Grammar got the best of me.

I have pasted the code to the OnOpen() event on the Drawing form.
Jun 2 '10 #7
This is a copy of the amended code if it makes it easier to see what I'm trying to do.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim varPictureToLoad
  3.  
  4. Me![PartNumber] = Me.OpenArgs
  5.  
  6. varPictureToLoad = DLookup("[Drawing]", "NewParts", "[Part Number] = '" & Me.OpenArgs & "'")
  7.  
  8. If IsNull(varPictureToLoad) Then
  9.   MsgBox "No Picture to Load", vbExclamation, "No Value in Field"
  10.     DoCmd.Close
  11. Else
  12.   If Dir$(varPictureToLoad) <> "" Then
  13.     Me![imgTest].Picture = varPictureToLoad
  14.   Else
  15.     MsgBox varPictureToLoad & " is not a valid Path", vbExclamation, "Invalid Path"
  16.       DoCmd.Close
  17.   End If
  18. End If
  19. End Sub
Jun 2 '10 #8
ADezii
8,834 Expert 8TB
@greeni91
Let me see your OpenForm() Statement where you are actually passing the OpenArgs Value.
Jun 2 '10 #9
@ADezii
What do you mean.... I only used both pieces of code that you gave me and that's all.

I don't think I have anything passing my OpenArgs value. The only thing is the code above that has OpenArgs mentioned in it.
Jun 2 '10 #10
ADezii
8,834 Expert 8TB
@greeni91
That explains it. You need to Open the 2nd Form with the Part Number passed within the OpenArgs Property. I did explain this to you in Post #4, Item #1. I'll repeat the code again, make you own substitutions for Form Name and Text Box Name containing the Part Number:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmImages", acNormal, , , acFormEdit, acWindowNormal, Me![txtPartNum] 
Jun 2 '10 #11
Yes I already have this code entered, but I have entered it to the Command button on the main form. Would this explain the problem??

The code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Drawing_Click()
  3. DoCmd.OpenForm "Drawing", acNormal, , , acFormEdit, acWindowNormal, Me![PartNo]
  4. End Sub
I am using this Command button to open the 2nd form and thought that was where you wanted the code.... Where exactly do you want the code to be placed (main form or second form) and what control will I link it to??
Jun 2 '10 #12
ADezii
8,834 Expert 8TB
@greeni91
Yes I already have this code entered, but I have entered it to the Command button on the main form. Would this explain the problem??
No
Can you Upload the Database, so I can take a look at it?
Jun 2 '10 #13
I tried to upload the database but Bytes.com said it is an invalid file extension... Could you give me an email address to send the database to you. Send it to me in a private email please so your addess isn't posted on the thread.

/Sandy
Jun 3 '10 #14

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

Similar topics

4
by: Brian Andrus | last post by:
Ok. I upgraded to MS Access 2003 recently and now I am having great heartache. In Access 2002, when I opened a table to view the data, there were wonderful little "plus" signs that I could click...
2
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting...
5
by: j.mandala | last post by:
Someone is trying to run my Access 2002 database under Access 2003. He has had a number of problems: 1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find it under 2003. Do I...
1
by: Matt Alanzo | last post by:
On another newsgroup an Access knowledgable party posted: >You should be able to connect an Access ADP to an existing SQLExpress >database running in SQLS 2000 compatibility mode. The only thing...
0
by: brian.flannery | last post by:
Greetings! I'm totally pulling what's left of my hair out. Down to business. I would like to know if it's possible to link most of the OL2003 Task fields to Access 2003. Most importantly, the...
4
by: Access | last post by:
Okay I know this is probably not the best way to be doing things but I have an ancient application that was working fine until a end user got a new machine. The Access database is performing a...
3
by: banba_ca | last post by:
When I create a new db from the main Access window or thru Vb (set newdb = ...) I always end up with Access 2000 file format. I would like to get 2002 - 2003 file format. The reason is that when I...
8
by: cgrider | last post by:
ok I ma having a problem trying to filter out extra data from a table to generate a report the table has a list of drawings and a particular project number associated with it so I created a report...
5
by: Jakob32 | last post by:
Hi I'm trying to link information from a query in another Access database to my own Access database using this code (which have worked fine for me earlier). SELECT * FROM MinHL IN...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.