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.
13 2026 @greeni91
Just subscribing, will return later. Is Part Number a String or Number?
@ADezii
The Part Number is set as a string as it begins with 2 letters, e.g. AG55470.
/Sandy
- Open the 2nd Form via the OpenForm() Method, and pass the Part Number via the OpenArgs Property (PartNum should be Required):
- DoCmd.OpenForm "frmImages", acNormal, , , acFormEdit, acWindowNormal, Me![txtPartNum]
- 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().
- Replace with your own Control/Form Names.
- Any questions, feel free to ask.
- Private Sub Form_Open(Cancel As Integer)
-
Dim varPictureToLoad
-
-
Me![txtPartNum] = Me.OpenArgs
-
-
varPictureToLoad = DLookup("[Path]", "tblImages", "[PartNum] = '" & Me.OpenArgs & "'")
-
-
If IsNull(varPictureToLoad) Then
-
MsgBox "No Picture to Load", vbExclamation, "No Value in Field"
-
DoCmd.Close
-
Else
-
If Dir$(varPictureToLoad) <> "" Then
-
Me![imgTest].Picture = varPictureToLoad
-
Else
-
MsgBox varPictureToLoad & " is not a valid Path", vbExclamation, "Invalid Path"
-
DoCmd.Close
-
End If
-
End If
-
End Sub
@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
@greeni91 - Is that a Comma or Period that I see after OpenArgs? If so, remove it.
- Did you place this Code in the Open() Event of the 2nd Form, the one containing the Image Control?
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.
This is a copy of the amended code if it makes it easier to see what I'm trying to do. - Private Sub Form_Open(Cancel As Integer)
-
Dim varPictureToLoad
-
-
Me![PartNumber] = Me.OpenArgs
-
-
varPictureToLoad = DLookup("[Drawing]", "NewParts", "[Part Number] = '" & Me.OpenArgs & "'")
-
-
If IsNull(varPictureToLoad) Then
-
MsgBox "No Picture to Load", vbExclamation, "No Value in Field"
-
DoCmd.Close
-
Else
-
If Dir$(varPictureToLoad) <> "" Then
-
Me![imgTest].Picture = varPictureToLoad
-
Else
-
MsgBox varPictureToLoad & " is not a valid Path", vbExclamation, "Invalid Path"
-
DoCmd.Close
-
End If
-
End If
-
End Sub
@greeni91
Let me see your OpenForm() Statement where you are actually passing the OpenArgs Value.
@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.
@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: - DoCmd.OpenForm "frmImages", acNormal, , , acFormEdit, acWindowNormal, Me![txtPartNum]
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: -
-
Private Sub Drawing_Click()
-
DoCmd.OpenForm "Drawing", acNormal, , , acFormEdit, acWindowNormal, Me![PartNo]
-
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??
@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?
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
|
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...
| |