473,770 Members | 4,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Minor Error with Code for Attaching Images to a Form

2 New Member
Hello

I don't know a thing about writing VBA Codes but this forum I was able thas helped me to finally figure out how to link the pictures to a path etc on a form. Everything works fine on the form - the pictures change with each employee etc, etc. However, when I select the command button "change picture" or "Remove", it opens the dialog box or the folder on the c:\drive etc and I can select a new picture or the one for deletion; BUT I also get a message which says compile error, syntax error and it highlights in yellow the name Private Sub cmdInsertPic_Cl ick(). The name of the form in which the employee data is stored is Employee Profile Form (from the table Employee Profile). The computer highlights the word "Profile" and gives the error (Expected =). It is possible that it is the spacing between the three words in the file name is the problem because if I were to rename the form to a single word, it works. The section with the error is emboldened. The code is listed below. Any assistance you can provide would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdInsertPic_Click()
  2.  
  3.   Dim OFN As OPENFILENAME
  4.   On Error GoTo Err_cmdInsertPic_Click
  5.  
  6.   ' Set options for dialog box.
  7.   With OFN
  8.     .lpstrTitle = "Images"
  9.     If Not IsNull([ImagePath]) Then .lpstrFile = [ImagePath]
  10.     .flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
  11.     .lpstrFilter = MakeFilterString("Image files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf", _
  12.       "All files (*.*)", "*.*")
  13.   End With
  14.  
  15.   If OpenDialog(OFN) Then
  16.     [ImagePath] = OFN.lpstrFile
  17.     Forms!Employee Profile Form![ImageFrame].Picture = [ImagePath]
  18.     SysCmd acSysCmdSetStatus, "Afbeelding: '" & [ImagePath] & "'."
  19.   End If
  20.   Exit Sub
  21.  
  22. Err_cmdInsertPic_Click:
  23.   MsgBox Err.Description, vbExclamation
  24. End Sub
Thanks
Forsi
Aug 15 '08 #1
1 1488
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I added code tags round your code to aid readability. As you may see above, it makes it much easier to differentiate one line from another.

The problem you are experiencing (at what is now line 17 above) results from the spaces in the form name, as you surmised. All such names - of fields, forms, reports, controls and so on - must be enclosed in rectangular brackets '[' and ']' if they contain spaces. A corrected version is shown below.

Expand|Select|Wrap|Line Numbers
  1.     Forms![Employee Profile Form]![ImageFrame].Picture = [ImagePath]
  2.     SysCmd acSysCmdSetStatus, "Afbeelding: '" & [ImagePath] & "'."
The error message generated by the compiler arose because without the brackets it considered that the name of the object or variable concerned ended at the space after the word Employee - and it expected an operator such as "=" to follow.

-Stewart
Aug 15 '08 #2

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

Similar topics

3
2932
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
3
4622
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that the user has to use my New Record button. When you click the New Record button, the form presents a new record for editing. My client wants to use the Escape key to cancel changes to new or existing records. On existing records, Access already...
0
1600
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520" AutoPostBackOnNodeMove="false" DragAndDropEnabled="true" NodeEditingEnabled="False" KeyboardEnabled="true" CssClass="TreeView" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode" HoverNodeCssClass="HoverTreeNode" NodeEditCssClass="NodeEdit"
2
4438
by: VB Programmer | last post by:
I only have 1 set of <FORM> tags in my HTML file, but I keep getting this error. Any ideas? *********** A page can have only one server-side Form tag. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A page can have only one
12
1892
by: Joel Byrd | last post by:
I am making an AJAX call when any one of a number of inputs in a form (search criteria) are clicked, checked, changed, etc. When the user clicks, checks, whatever, I am trying to display a "Retrieving results..." text. This should be really simple, but in IE, it does not work. Here's the code that is not executing in IE: And here is the context of that code, which is the AJAX function that is called when a radio button is clicked,...
1
3887
by: mudasserrafiq | last post by:
I am using following asp file default.asp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="0 Days" name=revisit-after> <META content=info@siderinternational.com name=email> <META content="Omer Safdar" name=author> <META content=MegaStudios.com name=publisher> <META content="Copyright ©2005 - MegaStudios.com" name=copyright> <SCRIPT...
1
1748
by: finizaini | last post by:
I'm receiving an "Object Expected" Error (Line:309, Char:0). I'm confused as to what is happening.Also, I can't run this code using other browser such as Fire Fox. Thispage only can view using IE. Is there something that I'm missing? The error is pointing to <textarea name="tairbillno" cols="25" rows="4" wrap="HARD" id="tairbillno" ONKEYDOWN="return checkMaxRow(this, 10)"></textarea> Here is my code below: <HTML> <HEAD>...
9
3206
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9. <option>north</option> 10. <option>south</option>
3
3600
by: graphicssl | last post by:
Okay, so first of all, I'm a designer first and a light coder second (I'm only really trained with HTML and CSS). So I apologize for having to post about something that's probably super-trivial! I'm working on setting up a shopping cart for a one-product web site, and I'm using HTML and CSS, with ASP for the shopping cart. The ASP takes the information from the form on the shopping cart, and formats it in to two e-mails: one for the company...
0
10071
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.